copper3d 3.5.0 → 3.6.1
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/Scene/copperScene.d.ts +12 -0
- package/dist/Scene/copperScene.js +38 -44
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
- package/dist/Utils/surfaceAnnotation/MeshGraph.js +198 -0
- package/dist/Utils/surfaceAnnotation/MeshGraph.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +104 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js +403 -0
- package/dist/Utils/surfaceAnnotation/SurfaceAnnotator.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.js +105 -0
- package/dist/Utils/surfaceAnnotation/annotationStore.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/contourRender.js +57 -0
- package/dist/Utils/surfaceAnnotation/contourRender.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.js +43 -0
- package/dist/Utils/surfaceAnnotation/geodesicContour.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/index.d.ts +3 -0
- package/dist/Utils/surfaceAnnotation/index.js +2 -0
- package/dist/Utils/surfaceAnnotation/index.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.js +16 -0
- package/dist/Utils/surfaceAnnotation/pointMarkers.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.js +27 -0
- package/dist/Utils/surfaceAnnotation/raycastSurface.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.d.ts +26 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.js +50 -0
- package/dist/Utils/surfaceAnnotation/strokeContour.js.map +1 -0
- package/dist/Utils/surfaceAnnotation/types.d.ts +40 -0
- package/dist/Utils/surfaceAnnotation/types.js +26 -0
- package/dist/Utils/surfaceAnnotation/types.js.map +1 -0
- package/dist/bundle.esm.js +2883 -79
- package/dist/bundle.umd.js +2883 -78
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/types/Scene/copperScene.d.ts +12 -0
- package/dist/types/Utils/surfaceAnnotation/MeshGraph.d.ts +40 -0
- package/dist/types/Utils/surfaceAnnotation/SurfaceAnnotator.d.ts +104 -0
- package/dist/types/Utils/surfaceAnnotation/annotationStore.d.ts +37 -0
- package/dist/types/Utils/surfaceAnnotation/contourRender.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/geodesicContour.d.ts +19 -0
- package/dist/types/Utils/surfaceAnnotation/index.d.ts +3 -0
- package/dist/types/Utils/surfaceAnnotation/pointMarkers.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/raycastSurface.d.ts +7 -0
- package/dist/types/Utils/surfaceAnnotation/strokeContour.d.ts +26 -0
- package/dist/types/Utils/surfaceAnnotation/types.d.ts +40 -0
- package/dist/types/index.d.ts +5 -3
- package/package.json +1 -1
package/dist/bundle.esm.js
CHANGED
|
@@ -18015,7 +18015,7 @@ const mat2array = new Float32Array( 4 );
|
|
|
18015
18015
|
|
|
18016
18016
|
// Flattening for arrays of vectors and matrices
|
|
18017
18017
|
|
|
18018
|
-
function flatten( array, nBlocks, blockSize ) {
|
|
18018
|
+
function flatten$1( array, nBlocks, blockSize ) {
|
|
18019
18019
|
|
|
18020
18020
|
const firstElem = array[ 0 ];
|
|
18021
18021
|
|
|
@@ -18643,7 +18643,7 @@ function setValueV1fArray( gl, v ) {
|
|
|
18643
18643
|
|
|
18644
18644
|
function setValueV2fArray( gl, v ) {
|
|
18645
18645
|
|
|
18646
|
-
const data = flatten( v, this.size, 2 );
|
|
18646
|
+
const data = flatten$1( v, this.size, 2 );
|
|
18647
18647
|
|
|
18648
18648
|
gl.uniform2fv( this.addr, data );
|
|
18649
18649
|
|
|
@@ -18651,7 +18651,7 @@ function setValueV2fArray( gl, v ) {
|
|
|
18651
18651
|
|
|
18652
18652
|
function setValueV3fArray( gl, v ) {
|
|
18653
18653
|
|
|
18654
|
-
const data = flatten( v, this.size, 3 );
|
|
18654
|
+
const data = flatten$1( v, this.size, 3 );
|
|
18655
18655
|
|
|
18656
18656
|
gl.uniform3fv( this.addr, data );
|
|
18657
18657
|
|
|
@@ -18659,7 +18659,7 @@ function setValueV3fArray( gl, v ) {
|
|
|
18659
18659
|
|
|
18660
18660
|
function setValueV4fArray( gl, v ) {
|
|
18661
18661
|
|
|
18662
|
-
const data = flatten( v, this.size, 4 );
|
|
18662
|
+
const data = flatten$1( v, this.size, 4 );
|
|
18663
18663
|
|
|
18664
18664
|
gl.uniform4fv( this.addr, data );
|
|
18665
18665
|
|
|
@@ -18669,7 +18669,7 @@ function setValueV4fArray( gl, v ) {
|
|
|
18669
18669
|
|
|
18670
18670
|
function setValueM2Array( gl, v ) {
|
|
18671
18671
|
|
|
18672
|
-
const data = flatten( v, this.size, 4 );
|
|
18672
|
+
const data = flatten$1( v, this.size, 4 );
|
|
18673
18673
|
|
|
18674
18674
|
gl.uniformMatrix2fv( this.addr, false, data );
|
|
18675
18675
|
|
|
@@ -18677,7 +18677,7 @@ function setValueM2Array( gl, v ) {
|
|
|
18677
18677
|
|
|
18678
18678
|
function setValueM3Array( gl, v ) {
|
|
18679
18679
|
|
|
18680
|
-
const data = flatten( v, this.size, 9 );
|
|
18680
|
+
const data = flatten$1( v, this.size, 9 );
|
|
18681
18681
|
|
|
18682
18682
|
gl.uniformMatrix3fv( this.addr, false, data );
|
|
18683
18683
|
|
|
@@ -18685,7 +18685,7 @@ function setValueM3Array( gl, v ) {
|
|
|
18685
18685
|
|
|
18686
18686
|
function setValueM4Array( gl, v ) {
|
|
18687
18687
|
|
|
18688
|
-
const data = flatten( v, this.size, 16 );
|
|
18688
|
+
const data = flatten$1( v, this.size, 16 );
|
|
18689
18689
|
|
|
18690
18690
|
gl.uniformMatrix4fv( this.addr, false, data );
|
|
18691
18691
|
|
|
@@ -33060,7 +33060,7 @@ const _vStart = /*@__PURE__*/ new Vector3();
|
|
|
33060
33060
|
const _vEnd = /*@__PURE__*/ new Vector3();
|
|
33061
33061
|
|
|
33062
33062
|
const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
|
|
33063
|
-
const _ray$1 = /*@__PURE__*/ new Ray();
|
|
33063
|
+
const _ray$1$1 = /*@__PURE__*/ new Ray();
|
|
33064
33064
|
const _sphere$1 = /*@__PURE__*/ new Sphere();
|
|
33065
33065
|
|
|
33066
33066
|
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
|
@@ -33147,7 +33147,7 @@ class Line extends Object3D {
|
|
|
33147
33147
|
//
|
|
33148
33148
|
|
|
33149
33149
|
_inverseMatrix$1.copy( matrixWorld ).invert();
|
|
33150
|
-
_ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
33150
|
+
_ray$1$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 );
|
|
33151
33151
|
|
|
33152
33152
|
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
|
33153
33153
|
const localThresholdSq = localThreshold * localThreshold;
|
|
@@ -33168,7 +33168,7 @@ class Line extends Object3D {
|
|
|
33168
33168
|
const a = index.getX( i );
|
|
33169
33169
|
const b = index.getX( i + 1 );
|
|
33170
33170
|
|
|
33171
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
33171
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, a, b );
|
|
33172
33172
|
|
|
33173
33173
|
if ( intersect ) {
|
|
33174
33174
|
|
|
@@ -33183,7 +33183,7 @@ class Line extends Object3D {
|
|
|
33183
33183
|
const a = index.getX( end - 1 );
|
|
33184
33184
|
const b = index.getX( start );
|
|
33185
33185
|
|
|
33186
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
|
|
33186
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, a, b );
|
|
33187
33187
|
|
|
33188
33188
|
if ( intersect ) {
|
|
33189
33189
|
|
|
@@ -33200,7 +33200,7 @@ class Line extends Object3D {
|
|
|
33200
33200
|
|
|
33201
33201
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
33202
33202
|
|
|
33203
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
|
|
33203
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, i, i + 1 );
|
|
33204
33204
|
|
|
33205
33205
|
if ( intersect ) {
|
|
33206
33206
|
|
|
@@ -33212,7 +33212,7 @@ class Line extends Object3D {
|
|
|
33212
33212
|
|
|
33213
33213
|
if ( this.isLineLoop ) {
|
|
33214
33214
|
|
|
33215
|
-
const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
|
|
33215
|
+
const intersect = checkIntersection( this, raycaster, _ray$1$1, localThresholdSq, end - 1, start );
|
|
33216
33216
|
|
|
33217
33217
|
if ( intersect ) {
|
|
33218
33218
|
|
|
@@ -33292,8 +33292,8 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
|
33292
33292
|
|
|
33293
33293
|
}
|
|
33294
33294
|
|
|
33295
|
-
const _start = /*@__PURE__*/ new Vector3();
|
|
33296
|
-
const _end = /*@__PURE__*/ new Vector3();
|
|
33295
|
+
const _start$1 = /*@__PURE__*/ new Vector3();
|
|
33296
|
+
const _end$1 = /*@__PURE__*/ new Vector3();
|
|
33297
33297
|
|
|
33298
33298
|
class LineSegments extends Line {
|
|
33299
33299
|
|
|
@@ -33320,11 +33320,11 @@ class LineSegments extends Line {
|
|
|
33320
33320
|
|
|
33321
33321
|
for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {
|
|
33322
33322
|
|
|
33323
|
-
_start.fromBufferAttribute( positionAttribute, i );
|
|
33324
|
-
_end.fromBufferAttribute( positionAttribute, i + 1 );
|
|
33323
|
+
_start$1.fromBufferAttribute( positionAttribute, i );
|
|
33324
|
+
_end$1.fromBufferAttribute( positionAttribute, i + 1 );
|
|
33325
33325
|
|
|
33326
33326
|
lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];
|
|
33327
|
-
lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );
|
|
33327
|
+
lineDistances[ i + 1 ] = lineDistances[ i ] + _start$1.distanceTo( _end$1 );
|
|
33328
33328
|
|
|
33329
33329
|
}
|
|
33330
33330
|
|
|
@@ -33408,7 +33408,7 @@ class PointsMaterial extends Material {
|
|
|
33408
33408
|
|
|
33409
33409
|
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
|
33410
33410
|
const _ray$4 = /*@__PURE__*/ new Ray();
|
|
33411
|
-
const _sphere = /*@__PURE__*/ new Sphere();
|
|
33411
|
+
const _sphere$2 = /*@__PURE__*/ new Sphere();
|
|
33412
33412
|
const _position$2 = /*@__PURE__*/ new Vector3();
|
|
33413
33413
|
|
|
33414
33414
|
class Points extends Object3D {
|
|
@@ -33450,11 +33450,11 @@ class Points extends Object3D {
|
|
|
33450
33450
|
|
|
33451
33451
|
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
33452
33452
|
|
|
33453
|
-
_sphere.copy( geometry.boundingSphere );
|
|
33454
|
-
_sphere.applyMatrix4( matrixWorld );
|
|
33455
|
-
_sphere.radius += threshold;
|
|
33453
|
+
_sphere$2.copy( geometry.boundingSphere );
|
|
33454
|
+
_sphere$2.applyMatrix4( matrixWorld );
|
|
33455
|
+
_sphere$2.radius += threshold;
|
|
33456
33456
|
|
|
33457
|
-
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
|
33457
|
+
if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return;
|
|
33458
33458
|
|
|
33459
33459
|
//
|
|
33460
33460
|
|
|
@@ -33754,6 +33754,279 @@ class RingGeometry extends BufferGeometry {
|
|
|
33754
33754
|
|
|
33755
33755
|
}
|
|
33756
33756
|
|
|
33757
|
+
class SphereGeometry extends BufferGeometry {
|
|
33758
|
+
|
|
33759
|
+
constructor( radius = 1, widthSegments = 32, heightSegments = 16, phiStart = 0, phiLength = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI ) {
|
|
33760
|
+
|
|
33761
|
+
super();
|
|
33762
|
+
|
|
33763
|
+
this.type = 'SphereGeometry';
|
|
33764
|
+
|
|
33765
|
+
this.parameters = {
|
|
33766
|
+
radius: radius,
|
|
33767
|
+
widthSegments: widthSegments,
|
|
33768
|
+
heightSegments: heightSegments,
|
|
33769
|
+
phiStart: phiStart,
|
|
33770
|
+
phiLength: phiLength,
|
|
33771
|
+
thetaStart: thetaStart,
|
|
33772
|
+
thetaLength: thetaLength
|
|
33773
|
+
};
|
|
33774
|
+
|
|
33775
|
+
widthSegments = Math.max( 3, Math.floor( widthSegments ) );
|
|
33776
|
+
heightSegments = Math.max( 2, Math.floor( heightSegments ) );
|
|
33777
|
+
|
|
33778
|
+
const thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
|
|
33779
|
+
|
|
33780
|
+
let index = 0;
|
|
33781
|
+
const grid = [];
|
|
33782
|
+
|
|
33783
|
+
const vertex = new Vector3();
|
|
33784
|
+
const normal = new Vector3();
|
|
33785
|
+
|
|
33786
|
+
// buffers
|
|
33787
|
+
|
|
33788
|
+
const indices = [];
|
|
33789
|
+
const vertices = [];
|
|
33790
|
+
const normals = [];
|
|
33791
|
+
const uvs = [];
|
|
33792
|
+
|
|
33793
|
+
// generate vertices, normals and uvs
|
|
33794
|
+
|
|
33795
|
+
for ( let iy = 0; iy <= heightSegments; iy ++ ) {
|
|
33796
|
+
|
|
33797
|
+
const verticesRow = [];
|
|
33798
|
+
|
|
33799
|
+
const v = iy / heightSegments;
|
|
33800
|
+
|
|
33801
|
+
// special case for the poles
|
|
33802
|
+
|
|
33803
|
+
let uOffset = 0;
|
|
33804
|
+
|
|
33805
|
+
if ( iy === 0 && thetaStart === 0 ) {
|
|
33806
|
+
|
|
33807
|
+
uOffset = 0.5 / widthSegments;
|
|
33808
|
+
|
|
33809
|
+
} else if ( iy === heightSegments && thetaEnd === Math.PI ) {
|
|
33810
|
+
|
|
33811
|
+
uOffset = - 0.5 / widthSegments;
|
|
33812
|
+
|
|
33813
|
+
}
|
|
33814
|
+
|
|
33815
|
+
for ( let ix = 0; ix <= widthSegments; ix ++ ) {
|
|
33816
|
+
|
|
33817
|
+
const u = ix / widthSegments;
|
|
33818
|
+
|
|
33819
|
+
// vertex
|
|
33820
|
+
|
|
33821
|
+
vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
33822
|
+
vertex.y = radius * Math.cos( thetaStart + v * thetaLength );
|
|
33823
|
+
vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
33824
|
+
|
|
33825
|
+
vertices.push( vertex.x, vertex.y, vertex.z );
|
|
33826
|
+
|
|
33827
|
+
// normal
|
|
33828
|
+
|
|
33829
|
+
normal.copy( vertex ).normalize();
|
|
33830
|
+
normals.push( normal.x, normal.y, normal.z );
|
|
33831
|
+
|
|
33832
|
+
// uv
|
|
33833
|
+
|
|
33834
|
+
uvs.push( u + uOffset, 1 - v );
|
|
33835
|
+
|
|
33836
|
+
verticesRow.push( index ++ );
|
|
33837
|
+
|
|
33838
|
+
}
|
|
33839
|
+
|
|
33840
|
+
grid.push( verticesRow );
|
|
33841
|
+
|
|
33842
|
+
}
|
|
33843
|
+
|
|
33844
|
+
// indices
|
|
33845
|
+
|
|
33846
|
+
for ( let iy = 0; iy < heightSegments; iy ++ ) {
|
|
33847
|
+
|
|
33848
|
+
for ( let ix = 0; ix < widthSegments; ix ++ ) {
|
|
33849
|
+
|
|
33850
|
+
const a = grid[ iy ][ ix + 1 ];
|
|
33851
|
+
const b = grid[ iy ][ ix ];
|
|
33852
|
+
const c = grid[ iy + 1 ][ ix ];
|
|
33853
|
+
const d = grid[ iy + 1 ][ ix + 1 ];
|
|
33854
|
+
|
|
33855
|
+
if ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d );
|
|
33856
|
+
if ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d );
|
|
33857
|
+
|
|
33858
|
+
}
|
|
33859
|
+
|
|
33860
|
+
}
|
|
33861
|
+
|
|
33862
|
+
// build geometry
|
|
33863
|
+
|
|
33864
|
+
this.setIndex( indices );
|
|
33865
|
+
this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
33866
|
+
this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
|
|
33867
|
+
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
33868
|
+
|
|
33869
|
+
}
|
|
33870
|
+
|
|
33871
|
+
copy( source ) {
|
|
33872
|
+
|
|
33873
|
+
super.copy( source );
|
|
33874
|
+
|
|
33875
|
+
this.parameters = Object.assign( {}, source.parameters );
|
|
33876
|
+
|
|
33877
|
+
return this;
|
|
33878
|
+
|
|
33879
|
+
}
|
|
33880
|
+
|
|
33881
|
+
static fromJSON( data ) {
|
|
33882
|
+
|
|
33883
|
+
return new SphereGeometry( data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength );
|
|
33884
|
+
|
|
33885
|
+
}
|
|
33886
|
+
|
|
33887
|
+
}
|
|
33888
|
+
|
|
33889
|
+
class WireframeGeometry extends BufferGeometry {
|
|
33890
|
+
|
|
33891
|
+
constructor( geometry = null ) {
|
|
33892
|
+
|
|
33893
|
+
super();
|
|
33894
|
+
|
|
33895
|
+
this.type = 'WireframeGeometry';
|
|
33896
|
+
|
|
33897
|
+
this.parameters = {
|
|
33898
|
+
geometry: geometry
|
|
33899
|
+
};
|
|
33900
|
+
|
|
33901
|
+
if ( geometry !== null ) {
|
|
33902
|
+
|
|
33903
|
+
// buffer
|
|
33904
|
+
|
|
33905
|
+
const vertices = [];
|
|
33906
|
+
const edges = new Set();
|
|
33907
|
+
|
|
33908
|
+
// helper variables
|
|
33909
|
+
|
|
33910
|
+
const start = new Vector3();
|
|
33911
|
+
const end = new Vector3();
|
|
33912
|
+
|
|
33913
|
+
if ( geometry.index !== null ) {
|
|
33914
|
+
|
|
33915
|
+
// indexed BufferGeometry
|
|
33916
|
+
|
|
33917
|
+
const position = geometry.attributes.position;
|
|
33918
|
+
const indices = geometry.index;
|
|
33919
|
+
let groups = geometry.groups;
|
|
33920
|
+
|
|
33921
|
+
if ( groups.length === 0 ) {
|
|
33922
|
+
|
|
33923
|
+
groups = [ { start: 0, count: indices.count, materialIndex: 0 } ];
|
|
33924
|
+
|
|
33925
|
+
}
|
|
33926
|
+
|
|
33927
|
+
// create a data structure that contains all edges without duplicates
|
|
33928
|
+
|
|
33929
|
+
for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
|
|
33930
|
+
|
|
33931
|
+
const group = groups[ o ];
|
|
33932
|
+
|
|
33933
|
+
const groupStart = group.start;
|
|
33934
|
+
const groupCount = group.count;
|
|
33935
|
+
|
|
33936
|
+
for ( let i = groupStart, l = ( groupStart + groupCount ); i < l; i += 3 ) {
|
|
33937
|
+
|
|
33938
|
+
for ( let j = 0; j < 3; j ++ ) {
|
|
33939
|
+
|
|
33940
|
+
const index1 = indices.getX( i + j );
|
|
33941
|
+
const index2 = indices.getX( i + ( j + 1 ) % 3 );
|
|
33942
|
+
|
|
33943
|
+
start.fromBufferAttribute( position, index1 );
|
|
33944
|
+
end.fromBufferAttribute( position, index2 );
|
|
33945
|
+
|
|
33946
|
+
if ( isUniqueEdge( start, end, edges ) === true ) {
|
|
33947
|
+
|
|
33948
|
+
vertices.push( start.x, start.y, start.z );
|
|
33949
|
+
vertices.push( end.x, end.y, end.z );
|
|
33950
|
+
|
|
33951
|
+
}
|
|
33952
|
+
|
|
33953
|
+
}
|
|
33954
|
+
|
|
33955
|
+
}
|
|
33956
|
+
|
|
33957
|
+
}
|
|
33958
|
+
|
|
33959
|
+
} else {
|
|
33960
|
+
|
|
33961
|
+
// non-indexed BufferGeometry
|
|
33962
|
+
|
|
33963
|
+
const position = geometry.attributes.position;
|
|
33964
|
+
|
|
33965
|
+
for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
|
|
33966
|
+
|
|
33967
|
+
for ( let j = 0; j < 3; j ++ ) {
|
|
33968
|
+
|
|
33969
|
+
// three edges per triangle, an edge is represented as (index1, index2)
|
|
33970
|
+
// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
|
|
33971
|
+
|
|
33972
|
+
const index1 = 3 * i + j;
|
|
33973
|
+
const index2 = 3 * i + ( ( j + 1 ) % 3 );
|
|
33974
|
+
|
|
33975
|
+
start.fromBufferAttribute( position, index1 );
|
|
33976
|
+
end.fromBufferAttribute( position, index2 );
|
|
33977
|
+
|
|
33978
|
+
if ( isUniqueEdge( start, end, edges ) === true ) {
|
|
33979
|
+
|
|
33980
|
+
vertices.push( start.x, start.y, start.z );
|
|
33981
|
+
vertices.push( end.x, end.y, end.z );
|
|
33982
|
+
|
|
33983
|
+
}
|
|
33984
|
+
|
|
33985
|
+
}
|
|
33986
|
+
|
|
33987
|
+
}
|
|
33988
|
+
|
|
33989
|
+
}
|
|
33990
|
+
|
|
33991
|
+
// build geometry
|
|
33992
|
+
|
|
33993
|
+
this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
33994
|
+
|
|
33995
|
+
}
|
|
33996
|
+
|
|
33997
|
+
}
|
|
33998
|
+
|
|
33999
|
+
copy( source ) {
|
|
34000
|
+
|
|
34001
|
+
super.copy( source );
|
|
34002
|
+
|
|
34003
|
+
this.parameters = Object.assign( {}, source.parameters );
|
|
34004
|
+
|
|
34005
|
+
return this;
|
|
34006
|
+
|
|
34007
|
+
}
|
|
34008
|
+
|
|
34009
|
+
}
|
|
34010
|
+
|
|
34011
|
+
function isUniqueEdge( start, end, edges ) {
|
|
34012
|
+
|
|
34013
|
+
const hash1 = `${start.x},${start.y},${start.z}-${end.x},${end.y},${end.z}`;
|
|
34014
|
+
const hash2 = `${end.x},${end.y},${end.z}-${start.x},${start.y},${start.z}`; // coincident edge
|
|
34015
|
+
|
|
34016
|
+
if ( edges.has( hash1 ) === true || edges.has( hash2 ) === true ) {
|
|
34017
|
+
|
|
34018
|
+
return false;
|
|
34019
|
+
|
|
34020
|
+
} else {
|
|
34021
|
+
|
|
34022
|
+
edges.add( hash1 );
|
|
34023
|
+
edges.add( hash2 );
|
|
34024
|
+
return true;
|
|
34025
|
+
|
|
34026
|
+
}
|
|
34027
|
+
|
|
34028
|
+
}
|
|
34029
|
+
|
|
33757
34030
|
class RawShaderMaterial extends ShaderMaterial {
|
|
33758
34031
|
|
|
33759
34032
|
static get type() {
|
|
@@ -37262,6 +37535,43 @@ class LoaderUtils {
|
|
|
37262
37535
|
|
|
37263
37536
|
}
|
|
37264
37537
|
|
|
37538
|
+
class InstancedBufferGeometry extends BufferGeometry {
|
|
37539
|
+
|
|
37540
|
+
constructor() {
|
|
37541
|
+
|
|
37542
|
+
super();
|
|
37543
|
+
|
|
37544
|
+
this.isInstancedBufferGeometry = true;
|
|
37545
|
+
|
|
37546
|
+
this.type = 'InstancedBufferGeometry';
|
|
37547
|
+
this.instanceCount = Infinity;
|
|
37548
|
+
|
|
37549
|
+
}
|
|
37550
|
+
|
|
37551
|
+
copy( source ) {
|
|
37552
|
+
|
|
37553
|
+
super.copy( source );
|
|
37554
|
+
|
|
37555
|
+
this.instanceCount = source.instanceCount;
|
|
37556
|
+
|
|
37557
|
+
return this;
|
|
37558
|
+
|
|
37559
|
+
}
|
|
37560
|
+
|
|
37561
|
+
toJSON() {
|
|
37562
|
+
|
|
37563
|
+
const data = super.toJSON();
|
|
37564
|
+
|
|
37565
|
+
data.instanceCount = this.instanceCount;
|
|
37566
|
+
|
|
37567
|
+
data.isInstancedBufferGeometry = true;
|
|
37568
|
+
|
|
37569
|
+
return data;
|
|
37570
|
+
|
|
37571
|
+
}
|
|
37572
|
+
|
|
37573
|
+
}
|
|
37574
|
+
|
|
37265
37575
|
class ImageBitmapLoader extends Loader {
|
|
37266
37576
|
|
|
37267
37577
|
constructor( manager ) {
|
|
@@ -39940,6 +40250,51 @@ class AnimationMixer extends EventDispatcher {
|
|
|
39940
40250
|
|
|
39941
40251
|
}
|
|
39942
40252
|
|
|
40253
|
+
class InstancedInterleavedBuffer extends InterleavedBuffer {
|
|
40254
|
+
|
|
40255
|
+
constructor( array, stride, meshPerAttribute = 1 ) {
|
|
40256
|
+
|
|
40257
|
+
super( array, stride );
|
|
40258
|
+
|
|
40259
|
+
this.isInstancedInterleavedBuffer = true;
|
|
40260
|
+
|
|
40261
|
+
this.meshPerAttribute = meshPerAttribute;
|
|
40262
|
+
|
|
40263
|
+
}
|
|
40264
|
+
|
|
40265
|
+
copy( source ) {
|
|
40266
|
+
|
|
40267
|
+
super.copy( source );
|
|
40268
|
+
|
|
40269
|
+
this.meshPerAttribute = source.meshPerAttribute;
|
|
40270
|
+
|
|
40271
|
+
return this;
|
|
40272
|
+
|
|
40273
|
+
}
|
|
40274
|
+
|
|
40275
|
+
clone( data ) {
|
|
40276
|
+
|
|
40277
|
+
const ib = super.clone( data );
|
|
40278
|
+
|
|
40279
|
+
ib.meshPerAttribute = this.meshPerAttribute;
|
|
40280
|
+
|
|
40281
|
+
return ib;
|
|
40282
|
+
|
|
40283
|
+
}
|
|
40284
|
+
|
|
40285
|
+
toJSON( data ) {
|
|
40286
|
+
|
|
40287
|
+
const json = super.toJSON( data );
|
|
40288
|
+
|
|
40289
|
+
json.isInstancedInterleavedBuffer = true;
|
|
40290
|
+
json.meshPerAttribute = this.meshPerAttribute;
|
|
40291
|
+
|
|
40292
|
+
return json;
|
|
40293
|
+
|
|
40294
|
+
}
|
|
40295
|
+
|
|
40296
|
+
}
|
|
40297
|
+
|
|
39943
40298
|
const _matrix = /*@__PURE__*/ new Matrix4();
|
|
39944
40299
|
|
|
39945
40300
|
class Raycaster {
|
|
@@ -40145,7 +40500,118 @@ class Spherical {
|
|
|
40145
40500
|
|
|
40146
40501
|
}
|
|
40147
40502
|
|
|
40148
|
-
const
|
|
40503
|
+
const _startP = /*@__PURE__*/ new Vector3();
|
|
40504
|
+
const _startEnd = /*@__PURE__*/ new Vector3();
|
|
40505
|
+
|
|
40506
|
+
class Line3 {
|
|
40507
|
+
|
|
40508
|
+
constructor( start = new Vector3(), end = new Vector3() ) {
|
|
40509
|
+
|
|
40510
|
+
this.start = start;
|
|
40511
|
+
this.end = end;
|
|
40512
|
+
|
|
40513
|
+
}
|
|
40514
|
+
|
|
40515
|
+
set( start, end ) {
|
|
40516
|
+
|
|
40517
|
+
this.start.copy( start );
|
|
40518
|
+
this.end.copy( end );
|
|
40519
|
+
|
|
40520
|
+
return this;
|
|
40521
|
+
|
|
40522
|
+
}
|
|
40523
|
+
|
|
40524
|
+
copy( line ) {
|
|
40525
|
+
|
|
40526
|
+
this.start.copy( line.start );
|
|
40527
|
+
this.end.copy( line.end );
|
|
40528
|
+
|
|
40529
|
+
return this;
|
|
40530
|
+
|
|
40531
|
+
}
|
|
40532
|
+
|
|
40533
|
+
getCenter( target ) {
|
|
40534
|
+
|
|
40535
|
+
return target.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
|
|
40536
|
+
|
|
40537
|
+
}
|
|
40538
|
+
|
|
40539
|
+
delta( target ) {
|
|
40540
|
+
|
|
40541
|
+
return target.subVectors( this.end, this.start );
|
|
40542
|
+
|
|
40543
|
+
}
|
|
40544
|
+
|
|
40545
|
+
distanceSq() {
|
|
40546
|
+
|
|
40547
|
+
return this.start.distanceToSquared( this.end );
|
|
40548
|
+
|
|
40549
|
+
}
|
|
40550
|
+
|
|
40551
|
+
distance() {
|
|
40552
|
+
|
|
40553
|
+
return this.start.distanceTo( this.end );
|
|
40554
|
+
|
|
40555
|
+
}
|
|
40556
|
+
|
|
40557
|
+
at( t, target ) {
|
|
40558
|
+
|
|
40559
|
+
return this.delta( target ).multiplyScalar( t ).add( this.start );
|
|
40560
|
+
|
|
40561
|
+
}
|
|
40562
|
+
|
|
40563
|
+
closestPointToPointParameter( point, clampToLine ) {
|
|
40564
|
+
|
|
40565
|
+
_startP.subVectors( point, this.start );
|
|
40566
|
+
_startEnd.subVectors( this.end, this.start );
|
|
40567
|
+
|
|
40568
|
+
const startEnd2 = _startEnd.dot( _startEnd );
|
|
40569
|
+
const startEnd_startP = _startEnd.dot( _startP );
|
|
40570
|
+
|
|
40571
|
+
let t = startEnd_startP / startEnd2;
|
|
40572
|
+
|
|
40573
|
+
if ( clampToLine ) {
|
|
40574
|
+
|
|
40575
|
+
t = clamp( t, 0, 1 );
|
|
40576
|
+
|
|
40577
|
+
}
|
|
40578
|
+
|
|
40579
|
+
return t;
|
|
40580
|
+
|
|
40581
|
+
}
|
|
40582
|
+
|
|
40583
|
+
closestPointToPoint( point, clampToLine, target ) {
|
|
40584
|
+
|
|
40585
|
+
const t = this.closestPointToPointParameter( point, clampToLine );
|
|
40586
|
+
|
|
40587
|
+
return this.delta( target ).multiplyScalar( t ).add( this.start );
|
|
40588
|
+
|
|
40589
|
+
}
|
|
40590
|
+
|
|
40591
|
+
applyMatrix4( matrix ) {
|
|
40592
|
+
|
|
40593
|
+
this.start.applyMatrix4( matrix );
|
|
40594
|
+
this.end.applyMatrix4( matrix );
|
|
40595
|
+
|
|
40596
|
+
return this;
|
|
40597
|
+
|
|
40598
|
+
}
|
|
40599
|
+
|
|
40600
|
+
equals( line ) {
|
|
40601
|
+
|
|
40602
|
+
return line.start.equals( this.start ) && line.end.equals( this.end );
|
|
40603
|
+
|
|
40604
|
+
}
|
|
40605
|
+
|
|
40606
|
+
clone() {
|
|
40607
|
+
|
|
40608
|
+
return new this.constructor().copy( this );
|
|
40609
|
+
|
|
40610
|
+
}
|
|
40611
|
+
|
|
40612
|
+
}
|
|
40613
|
+
|
|
40614
|
+
const _box$5 = /*@__PURE__*/ new Box3();
|
|
40149
40615
|
|
|
40150
40616
|
class BoxHelper extends LineSegments {
|
|
40151
40617
|
|
|
@@ -40179,14 +40645,14 @@ class BoxHelper extends LineSegments {
|
|
|
40179
40645
|
|
|
40180
40646
|
if ( this.object !== undefined ) {
|
|
40181
40647
|
|
|
40182
|
-
_box.setFromObject( this.object );
|
|
40648
|
+
_box$5.setFromObject( this.object );
|
|
40183
40649
|
|
|
40184
40650
|
}
|
|
40185
40651
|
|
|
40186
|
-
if ( _box.isEmpty() ) return;
|
|
40652
|
+
if ( _box$5.isEmpty() ) return;
|
|
40187
40653
|
|
|
40188
|
-
const min = _box.min;
|
|
40189
|
-
const max = _box.max;
|
|
40654
|
+
const min = _box$5.min;
|
|
40655
|
+
const max = _box$5.max;
|
|
40190
40656
|
|
|
40191
40657
|
/*
|
|
40192
40658
|
5____4
|
|
@@ -47507,7 +47973,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
47507
47973
|
const _changeEvent$1 = { type: 'change' };
|
|
47508
47974
|
const _startEvent$1 = { type: 'start' };
|
|
47509
47975
|
const _endEvent$1 = { type: 'end' };
|
|
47510
|
-
const _ray = new Ray();
|
|
47976
|
+
const _ray$1 = new Ray();
|
|
47511
47977
|
const _plane = new Plane();
|
|
47512
47978
|
const _TILT_LIMIT = Math.cos( 70 * MathUtils.DEG2RAD );
|
|
47513
47979
|
|
|
@@ -47950,19 +48416,19 @@ class OrbitControls extends Controls$1 {
|
|
|
47950
48416
|
} else {
|
|
47951
48417
|
|
|
47952
48418
|
// get the ray and translation plane to compute target
|
|
47953
|
-
_ray.origin.copy( this.object.position );
|
|
47954
|
-
_ray.direction.set( 0, 0, - 1 ).transformDirection( this.object.matrix );
|
|
48419
|
+
_ray$1.origin.copy( this.object.position );
|
|
48420
|
+
_ray$1.direction.set( 0, 0, - 1 ).transformDirection( this.object.matrix );
|
|
47955
48421
|
|
|
47956
48422
|
// if the camera is 20 degrees above the horizon then don't adjust the focus target to avoid
|
|
47957
48423
|
// extremely large values
|
|
47958
|
-
if ( Math.abs( this.object.up.dot( _ray.direction ) ) < _TILT_LIMIT ) {
|
|
48424
|
+
if ( Math.abs( this.object.up.dot( _ray$1.direction ) ) < _TILT_LIMIT ) {
|
|
47959
48425
|
|
|
47960
48426
|
this.object.lookAt( this.target );
|
|
47961
48427
|
|
|
47962
48428
|
} else {
|
|
47963
48429
|
|
|
47964
48430
|
_plane.setFromNormalAndCoplanarPoint( this.object.up, this.target );
|
|
47965
|
-
_ray.intersectPlane( _plane, this.target );
|
|
48431
|
+
_ray$1.intersectPlane( _plane, this.target );
|
|
47966
48432
|
|
|
47967
48433
|
}
|
|
47968
48434
|
|
|
@@ -50323,6 +50789,169 @@ class baseRenderer {
|
|
|
50323
50789
|
}
|
|
50324
50790
|
}
|
|
50325
50791
|
|
|
50792
|
+
/**
|
|
50793
|
+
* @param {BufferGeometry} geometry
|
|
50794
|
+
* @param {number} tolerance
|
|
50795
|
+
* @return {BufferGeometry}
|
|
50796
|
+
*/
|
|
50797
|
+
function mergeVertices( geometry, tolerance = 1e-4 ) {
|
|
50798
|
+
|
|
50799
|
+
tolerance = Math.max( tolerance, Number.EPSILON );
|
|
50800
|
+
|
|
50801
|
+
// Generate an index buffer if the geometry doesn't have one, or optimize it
|
|
50802
|
+
// if it's already available.
|
|
50803
|
+
const hashToIndex = {};
|
|
50804
|
+
const indices = geometry.getIndex();
|
|
50805
|
+
const positions = geometry.getAttribute( 'position' );
|
|
50806
|
+
const vertexCount = indices ? indices.count : positions.count;
|
|
50807
|
+
|
|
50808
|
+
// next value for triangle indices
|
|
50809
|
+
let nextIndex = 0;
|
|
50810
|
+
|
|
50811
|
+
// attributes and new attribute arrays
|
|
50812
|
+
const attributeNames = Object.keys( geometry.attributes );
|
|
50813
|
+
const tmpAttributes = {};
|
|
50814
|
+
const tmpMorphAttributes = {};
|
|
50815
|
+
const newIndices = [];
|
|
50816
|
+
const getters = [ 'getX', 'getY', 'getZ', 'getW' ];
|
|
50817
|
+
const setters = [ 'setX', 'setY', 'setZ', 'setW' ];
|
|
50818
|
+
|
|
50819
|
+
// Initialize the arrays, allocating space conservatively. Extra
|
|
50820
|
+
// space will be trimmed in the last step.
|
|
50821
|
+
for ( let i = 0, l = attributeNames.length; i < l; i ++ ) {
|
|
50822
|
+
|
|
50823
|
+
const name = attributeNames[ i ];
|
|
50824
|
+
const attr = geometry.attributes[ name ];
|
|
50825
|
+
|
|
50826
|
+
tmpAttributes[ name ] = new attr.constructor(
|
|
50827
|
+
new attr.array.constructor( attr.count * attr.itemSize ),
|
|
50828
|
+
attr.itemSize,
|
|
50829
|
+
attr.normalized
|
|
50830
|
+
);
|
|
50831
|
+
|
|
50832
|
+
const morphAttributes = geometry.morphAttributes[ name ];
|
|
50833
|
+
if ( morphAttributes ) {
|
|
50834
|
+
|
|
50835
|
+
if ( ! tmpMorphAttributes[ name ] ) tmpMorphAttributes[ name ] = [];
|
|
50836
|
+
morphAttributes.forEach( ( morphAttr, i ) => {
|
|
50837
|
+
|
|
50838
|
+
const array = new morphAttr.array.constructor( morphAttr.count * morphAttr.itemSize );
|
|
50839
|
+
tmpMorphAttributes[ name ][ i ] = new morphAttr.constructor( array, morphAttr.itemSize, morphAttr.normalized );
|
|
50840
|
+
|
|
50841
|
+
} );
|
|
50842
|
+
|
|
50843
|
+
}
|
|
50844
|
+
|
|
50845
|
+
}
|
|
50846
|
+
|
|
50847
|
+
// convert the error tolerance to an amount of decimal places to truncate to
|
|
50848
|
+
const halfTolerance = tolerance * 0.5;
|
|
50849
|
+
const exponent = Math.log10( 1 / tolerance );
|
|
50850
|
+
const hashMultiplier = Math.pow( 10, exponent );
|
|
50851
|
+
const hashAdditive = halfTolerance * hashMultiplier;
|
|
50852
|
+
for ( let i = 0; i < vertexCount; i ++ ) {
|
|
50853
|
+
|
|
50854
|
+
const index = indices ? indices.getX( i ) : i;
|
|
50855
|
+
|
|
50856
|
+
// Generate a hash for the vertex attributes at the current index 'i'
|
|
50857
|
+
let hash = '';
|
|
50858
|
+
for ( let j = 0, l = attributeNames.length; j < l; j ++ ) {
|
|
50859
|
+
|
|
50860
|
+
const name = attributeNames[ j ];
|
|
50861
|
+
const attribute = geometry.getAttribute( name );
|
|
50862
|
+
const itemSize = attribute.itemSize;
|
|
50863
|
+
|
|
50864
|
+
for ( let k = 0; k < itemSize; k ++ ) {
|
|
50865
|
+
|
|
50866
|
+
// double tilde truncates the decimal value
|
|
50867
|
+
hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * hashMultiplier + hashAdditive ) },`;
|
|
50868
|
+
|
|
50869
|
+
}
|
|
50870
|
+
|
|
50871
|
+
}
|
|
50872
|
+
|
|
50873
|
+
// Add another reference to the vertex if it's already
|
|
50874
|
+
// used by another index
|
|
50875
|
+
if ( hash in hashToIndex ) {
|
|
50876
|
+
|
|
50877
|
+
newIndices.push( hashToIndex[ hash ] );
|
|
50878
|
+
|
|
50879
|
+
} else {
|
|
50880
|
+
|
|
50881
|
+
// copy data to the new index in the temporary attributes
|
|
50882
|
+
for ( let j = 0, l = attributeNames.length; j < l; j ++ ) {
|
|
50883
|
+
|
|
50884
|
+
const name = attributeNames[ j ];
|
|
50885
|
+
const attribute = geometry.getAttribute( name );
|
|
50886
|
+
const morphAttributes = geometry.morphAttributes[ name ];
|
|
50887
|
+
const itemSize = attribute.itemSize;
|
|
50888
|
+
const newArray = tmpAttributes[ name ];
|
|
50889
|
+
const newMorphArrays = tmpMorphAttributes[ name ];
|
|
50890
|
+
|
|
50891
|
+
for ( let k = 0; k < itemSize; k ++ ) {
|
|
50892
|
+
|
|
50893
|
+
const getterFunc = getters[ k ];
|
|
50894
|
+
const setterFunc = setters[ k ];
|
|
50895
|
+
newArray[ setterFunc ]( nextIndex, attribute[ getterFunc ]( index ) );
|
|
50896
|
+
|
|
50897
|
+
if ( morphAttributes ) {
|
|
50898
|
+
|
|
50899
|
+
for ( let m = 0, ml = morphAttributes.length; m < ml; m ++ ) {
|
|
50900
|
+
|
|
50901
|
+
newMorphArrays[ m ][ setterFunc ]( nextIndex, morphAttributes[ m ][ getterFunc ]( index ) );
|
|
50902
|
+
|
|
50903
|
+
}
|
|
50904
|
+
|
|
50905
|
+
}
|
|
50906
|
+
|
|
50907
|
+
}
|
|
50908
|
+
|
|
50909
|
+
}
|
|
50910
|
+
|
|
50911
|
+
hashToIndex[ hash ] = nextIndex;
|
|
50912
|
+
newIndices.push( nextIndex );
|
|
50913
|
+
nextIndex ++;
|
|
50914
|
+
|
|
50915
|
+
}
|
|
50916
|
+
|
|
50917
|
+
}
|
|
50918
|
+
|
|
50919
|
+
// generate result BufferGeometry
|
|
50920
|
+
const result = geometry.clone();
|
|
50921
|
+
for ( const name in geometry.attributes ) {
|
|
50922
|
+
|
|
50923
|
+
const tmpAttribute = tmpAttributes[ name ];
|
|
50924
|
+
|
|
50925
|
+
result.setAttribute( name, new tmpAttribute.constructor(
|
|
50926
|
+
tmpAttribute.array.slice( 0, nextIndex * tmpAttribute.itemSize ),
|
|
50927
|
+
tmpAttribute.itemSize,
|
|
50928
|
+
tmpAttribute.normalized,
|
|
50929
|
+
) );
|
|
50930
|
+
|
|
50931
|
+
if ( ! ( name in tmpMorphAttributes ) ) continue;
|
|
50932
|
+
|
|
50933
|
+
for ( let j = 0; j < tmpMorphAttributes[ name ].length; j ++ ) {
|
|
50934
|
+
|
|
50935
|
+
const tmpMorphAttribute = tmpMorphAttributes[ name ][ j ];
|
|
50936
|
+
|
|
50937
|
+
result.morphAttributes[ name ][ j ] = new tmpMorphAttribute.constructor(
|
|
50938
|
+
tmpMorphAttribute.array.slice( 0, nextIndex * tmpMorphAttribute.itemSize ),
|
|
50939
|
+
tmpMorphAttribute.itemSize,
|
|
50940
|
+
tmpMorphAttribute.normalized,
|
|
50941
|
+
);
|
|
50942
|
+
|
|
50943
|
+
}
|
|
50944
|
+
|
|
50945
|
+
}
|
|
50946
|
+
|
|
50947
|
+
// indices
|
|
50948
|
+
|
|
50949
|
+
result.setIndex( newIndices );
|
|
50950
|
+
|
|
50951
|
+
return result;
|
|
50952
|
+
|
|
50953
|
+
}
|
|
50954
|
+
|
|
50326
50955
|
/**
|
|
50327
50956
|
* @param {BufferGeometry} geometry
|
|
50328
50957
|
* @param {number} drawMode
|
|
@@ -58881,6 +59510,2188 @@ function onTouchEnd( event ) {
|
|
|
58881
59510
|
|
|
58882
59511
|
}
|
|
58883
59512
|
|
|
59513
|
+
const _inv = new Matrix4();
|
|
59514
|
+
/** 世界系命中点 → local 顶点(位置 worldToLocal,法线用逆变换)。 */
|
|
59515
|
+
function worldHitToLocalVertex(h, mesh) {
|
|
59516
|
+
const lp = mesh.worldToLocal(h.point.clone());
|
|
59517
|
+
_inv.copy(mesh.matrixWorld).invert();
|
|
59518
|
+
const ln = h.normal.clone().transformDirection(_inv).normalize();
|
|
59519
|
+
return {
|
|
59520
|
+
x: lp.x,
|
|
59521
|
+
y: lp.y,
|
|
59522
|
+
z: lp.z,
|
|
59523
|
+
nx: ln.x,
|
|
59524
|
+
ny: ln.y,
|
|
59525
|
+
nz: ln.z,
|
|
59526
|
+
faceIndex: h.faceIndex,
|
|
59527
|
+
};
|
|
59528
|
+
}
|
|
59529
|
+
const _nm = new Matrix3();
|
|
59530
|
+
/** local 顶点 → world 位置 + world 法线(供渲染)。 */
|
|
59531
|
+
function localVertexToWorld(v, mesh) {
|
|
59532
|
+
const p = new Vector3(v.x, v.y, v.z).applyMatrix4(mesh.matrixWorld);
|
|
59533
|
+
_nm.getNormalMatrix(mesh.matrixWorld);
|
|
59534
|
+
const n = new Vector3(v.nx, v.ny, v.nz).applyMatrix3(_nm).normalize();
|
|
59535
|
+
return { p, n };
|
|
59536
|
+
}
|
|
59537
|
+
|
|
59538
|
+
const ray = new Raycaster();
|
|
59539
|
+
const ndc = new Vector2();
|
|
59540
|
+
/**
|
|
59541
|
+
* 把屏幕坐标(clientX/Y)投射到 mesh 表面,返回命中点、world-space 法线与 faceIndex。
|
|
59542
|
+
* 未命中返回 null。本地实现,不依赖 Copper3D 未导出的 raycast 内部函数。
|
|
59543
|
+
*/
|
|
59544
|
+
function raycastSurface(camera, container, mesh, clientX, clientY) {
|
|
59545
|
+
var _a;
|
|
59546
|
+
const rect = container.getBoundingClientRect();
|
|
59547
|
+
ndc.x = ((clientX - rect.left) / rect.width) * 2 - 1;
|
|
59548
|
+
ndc.y = -((clientY - rect.top) / rect.height) * 2 + 1;
|
|
59549
|
+
ray.setFromCamera(ndc, camera);
|
|
59550
|
+
const hits = ray.intersectObject(mesh, false);
|
|
59551
|
+
if (hits.length === 0)
|
|
59552
|
+
return null;
|
|
59553
|
+
const h = hits[0];
|
|
59554
|
+
const point = h.point.clone();
|
|
59555
|
+
const normal = new Vector3(0, 0, 1);
|
|
59556
|
+
if (h.face) {
|
|
59557
|
+
normal.copy(h.face.normal);
|
|
59558
|
+
const nm = new Matrix3().getNormalMatrix(mesh.matrixWorld);
|
|
59559
|
+
normal.applyMatrix3(nm).normalize();
|
|
59560
|
+
}
|
|
59561
|
+
return { point, normal, faceIndex: (_a = h.faceIndex) !== null && _a !== void 0 ? _a : -1 };
|
|
59562
|
+
}
|
|
59563
|
+
|
|
59564
|
+
/**
|
|
59565
|
+
* 在 local 顶点处生成一个标记小球(fiducial)。local→world 后沿 world 法线略外移,
|
|
59566
|
+
* 避免一半埋进表面。radius 由调用方按模型 bbox 缩放传入。
|
|
59567
|
+
*/
|
|
59568
|
+
function makePointMarker(v, mesh, color, radius) {
|
|
59569
|
+
const geo = new SphereGeometry(radius, 16, 16);
|
|
59570
|
+
const mat = new MeshBasicMaterial({ color });
|
|
59571
|
+
const m = new Mesh(geo, mat);
|
|
59572
|
+
const { p, n } = localVertexToWorld(v, mesh);
|
|
59573
|
+
m.position.copy(p.addScaledVector(n, radius * 0.5));
|
|
59574
|
+
m.renderOrder = 999;
|
|
59575
|
+
return m;
|
|
59576
|
+
}
|
|
59577
|
+
|
|
59578
|
+
/**
|
|
59579
|
+
* 模式 A(自由手绘)一笔的状态机。
|
|
59580
|
+
* pointermove 时不断 addSample;与上一采样点世界距离 < minGap 的样本丢弃,避免过密。
|
|
59581
|
+
* 顶点以 local 存(由 mesh 把世界命中点转 local)。
|
|
59582
|
+
*/
|
|
59583
|
+
class StrokeContour {
|
|
59584
|
+
/**
|
|
59585
|
+
* @param minGap 采样最小间距(世界系),去抖
|
|
59586
|
+
* @param maxJump 跳变阈值(世界系):距离 > maxJump 且法线大幅翻转时丢弃该样本,
|
|
59587
|
+
* 避免笔触掠过沟缝/轮廓边时相邻点落在不同深度、直线段横穿模型。
|
|
59588
|
+
*/
|
|
59589
|
+
constructor(minGap, maxJump, mesh) {
|
|
59590
|
+
this.minGap = minGap;
|
|
59591
|
+
this.maxJump = maxJump;
|
|
59592
|
+
this.mesh = mesh;
|
|
59593
|
+
this.verts = [];
|
|
59594
|
+
this.last = new Vector3();
|
|
59595
|
+
this.lastNormal = new Vector3();
|
|
59596
|
+
this.has = false;
|
|
59597
|
+
}
|
|
59598
|
+
begin() {
|
|
59599
|
+
this.verts = [];
|
|
59600
|
+
this.has = false;
|
|
59601
|
+
}
|
|
59602
|
+
addSample(hit) {
|
|
59603
|
+
if (this.has) {
|
|
59604
|
+
const d = hit.point.distanceTo(this.last);
|
|
59605
|
+
if (d < this.minGap)
|
|
59606
|
+
return; // 太近,去抖
|
|
59607
|
+
// 跳变剔除:距离突然很大「且」法线大幅翻转(>~75°)→ 多半跳到了背面/远面,丢弃,
|
|
59608
|
+
// 否则相邻两点之间的直线段会横穿模型内部。两个条件同时满足才剔除:
|
|
59609
|
+
// 快速画(距离大、法线相近)不误删;画过尖锐棱边(法线变、距离近)也不误删。
|
|
59610
|
+
if (d > this.maxJump && hit.normal.dot(this.lastNormal) < 0.25)
|
|
59611
|
+
return;
|
|
59612
|
+
}
|
|
59613
|
+
this.verts.push(worldHitToLocalVertex(hit, this.mesh));
|
|
59614
|
+
this.last.copy(hit.point);
|
|
59615
|
+
this.lastNormal.copy(hit.normal);
|
|
59616
|
+
this.has = true;
|
|
59617
|
+
}
|
|
59618
|
+
get vertices() {
|
|
59619
|
+
return this.verts;
|
|
59620
|
+
}
|
|
59621
|
+
end() {
|
|
59622
|
+
return this.verts;
|
|
59623
|
+
}
|
|
59624
|
+
}
|
|
59625
|
+
|
|
59626
|
+
const _box$1 = new Box3();
|
|
59627
|
+
const _vector = new Vector3();
|
|
59628
|
+
|
|
59629
|
+
class LineSegmentsGeometry extends InstancedBufferGeometry {
|
|
59630
|
+
|
|
59631
|
+
constructor() {
|
|
59632
|
+
|
|
59633
|
+
super();
|
|
59634
|
+
|
|
59635
|
+
this.isLineSegmentsGeometry = true;
|
|
59636
|
+
|
|
59637
|
+
this.type = 'LineSegmentsGeometry';
|
|
59638
|
+
|
|
59639
|
+
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 ];
|
|
59640
|
+
const uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
|
|
59641
|
+
const index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
|
59642
|
+
|
|
59643
|
+
this.setIndex( index );
|
|
59644
|
+
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
|
59645
|
+
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
59646
|
+
|
|
59647
|
+
}
|
|
59648
|
+
|
|
59649
|
+
applyMatrix4( matrix ) {
|
|
59650
|
+
|
|
59651
|
+
const start = this.attributes.instanceStart;
|
|
59652
|
+
const end = this.attributes.instanceEnd;
|
|
59653
|
+
|
|
59654
|
+
if ( start !== undefined ) {
|
|
59655
|
+
|
|
59656
|
+
start.applyMatrix4( matrix );
|
|
59657
|
+
|
|
59658
|
+
end.applyMatrix4( matrix );
|
|
59659
|
+
|
|
59660
|
+
start.needsUpdate = true;
|
|
59661
|
+
|
|
59662
|
+
}
|
|
59663
|
+
|
|
59664
|
+
if ( this.boundingBox !== null ) {
|
|
59665
|
+
|
|
59666
|
+
this.computeBoundingBox();
|
|
59667
|
+
|
|
59668
|
+
}
|
|
59669
|
+
|
|
59670
|
+
if ( this.boundingSphere !== null ) {
|
|
59671
|
+
|
|
59672
|
+
this.computeBoundingSphere();
|
|
59673
|
+
|
|
59674
|
+
}
|
|
59675
|
+
|
|
59676
|
+
return this;
|
|
59677
|
+
|
|
59678
|
+
}
|
|
59679
|
+
|
|
59680
|
+
setPositions( array ) {
|
|
59681
|
+
|
|
59682
|
+
let lineSegments;
|
|
59683
|
+
|
|
59684
|
+
if ( array instanceof Float32Array ) {
|
|
59685
|
+
|
|
59686
|
+
lineSegments = array;
|
|
59687
|
+
|
|
59688
|
+
} else if ( Array.isArray( array ) ) {
|
|
59689
|
+
|
|
59690
|
+
lineSegments = new Float32Array( array );
|
|
59691
|
+
|
|
59692
|
+
}
|
|
59693
|
+
|
|
59694
|
+
const instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
|
59695
|
+
|
|
59696
|
+
this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
|
59697
|
+
this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
|
59698
|
+
|
|
59699
|
+
this.instanceCount = this.attributes.instanceStart.count;
|
|
59700
|
+
|
|
59701
|
+
//
|
|
59702
|
+
|
|
59703
|
+
this.computeBoundingBox();
|
|
59704
|
+
this.computeBoundingSphere();
|
|
59705
|
+
|
|
59706
|
+
return this;
|
|
59707
|
+
|
|
59708
|
+
}
|
|
59709
|
+
|
|
59710
|
+
setColors( array ) {
|
|
59711
|
+
|
|
59712
|
+
let colors;
|
|
59713
|
+
|
|
59714
|
+
if ( array instanceof Float32Array ) {
|
|
59715
|
+
|
|
59716
|
+
colors = array;
|
|
59717
|
+
|
|
59718
|
+
} else if ( Array.isArray( array ) ) {
|
|
59719
|
+
|
|
59720
|
+
colors = new Float32Array( array );
|
|
59721
|
+
|
|
59722
|
+
}
|
|
59723
|
+
|
|
59724
|
+
const instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
|
59725
|
+
|
|
59726
|
+
this.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
|
59727
|
+
this.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
|
59728
|
+
|
|
59729
|
+
return this;
|
|
59730
|
+
|
|
59731
|
+
}
|
|
59732
|
+
|
|
59733
|
+
fromWireframeGeometry( geometry ) {
|
|
59734
|
+
|
|
59735
|
+
this.setPositions( geometry.attributes.position.array );
|
|
59736
|
+
|
|
59737
|
+
return this;
|
|
59738
|
+
|
|
59739
|
+
}
|
|
59740
|
+
|
|
59741
|
+
fromEdgesGeometry( geometry ) {
|
|
59742
|
+
|
|
59743
|
+
this.setPositions( geometry.attributes.position.array );
|
|
59744
|
+
|
|
59745
|
+
return this;
|
|
59746
|
+
|
|
59747
|
+
}
|
|
59748
|
+
|
|
59749
|
+
fromMesh( mesh ) {
|
|
59750
|
+
|
|
59751
|
+
this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
|
|
59752
|
+
|
|
59753
|
+
// set colors, maybe
|
|
59754
|
+
|
|
59755
|
+
return this;
|
|
59756
|
+
|
|
59757
|
+
}
|
|
59758
|
+
|
|
59759
|
+
fromLineSegments( lineSegments ) {
|
|
59760
|
+
|
|
59761
|
+
const geometry = lineSegments.geometry;
|
|
59762
|
+
|
|
59763
|
+
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
59764
|
+
|
|
59765
|
+
// set colors, maybe
|
|
59766
|
+
|
|
59767
|
+
return this;
|
|
59768
|
+
|
|
59769
|
+
}
|
|
59770
|
+
|
|
59771
|
+
computeBoundingBox() {
|
|
59772
|
+
|
|
59773
|
+
if ( this.boundingBox === null ) {
|
|
59774
|
+
|
|
59775
|
+
this.boundingBox = new Box3();
|
|
59776
|
+
|
|
59777
|
+
}
|
|
59778
|
+
|
|
59779
|
+
const start = this.attributes.instanceStart;
|
|
59780
|
+
const end = this.attributes.instanceEnd;
|
|
59781
|
+
|
|
59782
|
+
if ( start !== undefined && end !== undefined ) {
|
|
59783
|
+
|
|
59784
|
+
this.boundingBox.setFromBufferAttribute( start );
|
|
59785
|
+
|
|
59786
|
+
_box$1.setFromBufferAttribute( end );
|
|
59787
|
+
|
|
59788
|
+
this.boundingBox.union( _box$1 );
|
|
59789
|
+
|
|
59790
|
+
}
|
|
59791
|
+
|
|
59792
|
+
}
|
|
59793
|
+
|
|
59794
|
+
computeBoundingSphere() {
|
|
59795
|
+
|
|
59796
|
+
if ( this.boundingSphere === null ) {
|
|
59797
|
+
|
|
59798
|
+
this.boundingSphere = new Sphere();
|
|
59799
|
+
|
|
59800
|
+
}
|
|
59801
|
+
|
|
59802
|
+
if ( this.boundingBox === null ) {
|
|
59803
|
+
|
|
59804
|
+
this.computeBoundingBox();
|
|
59805
|
+
|
|
59806
|
+
}
|
|
59807
|
+
|
|
59808
|
+
const start = this.attributes.instanceStart;
|
|
59809
|
+
const end = this.attributes.instanceEnd;
|
|
59810
|
+
|
|
59811
|
+
if ( start !== undefined && end !== undefined ) {
|
|
59812
|
+
|
|
59813
|
+
const center = this.boundingSphere.center;
|
|
59814
|
+
|
|
59815
|
+
this.boundingBox.getCenter( center );
|
|
59816
|
+
|
|
59817
|
+
let maxRadiusSq = 0;
|
|
59818
|
+
|
|
59819
|
+
for ( let i = 0, il = start.count; i < il; i ++ ) {
|
|
59820
|
+
|
|
59821
|
+
_vector.fromBufferAttribute( start, i );
|
|
59822
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
59823
|
+
|
|
59824
|
+
_vector.fromBufferAttribute( end, i );
|
|
59825
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );
|
|
59826
|
+
|
|
59827
|
+
}
|
|
59828
|
+
|
|
59829
|
+
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
59830
|
+
|
|
59831
|
+
if ( isNaN( this.boundingSphere.radius ) ) {
|
|
59832
|
+
|
|
59833
|
+
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
|
|
59834
|
+
|
|
59835
|
+
}
|
|
59836
|
+
|
|
59837
|
+
}
|
|
59838
|
+
|
|
59839
|
+
}
|
|
59840
|
+
|
|
59841
|
+
toJSON() {
|
|
59842
|
+
|
|
59843
|
+
// todo
|
|
59844
|
+
|
|
59845
|
+
}
|
|
59846
|
+
|
|
59847
|
+
applyMatrix( matrix ) {
|
|
59848
|
+
|
|
59849
|
+
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
|
|
59850
|
+
|
|
59851
|
+
return this.applyMatrix4( matrix );
|
|
59852
|
+
|
|
59853
|
+
}
|
|
59854
|
+
|
|
59855
|
+
}
|
|
59856
|
+
|
|
59857
|
+
UniformsLib.line = {
|
|
59858
|
+
|
|
59859
|
+
worldUnits: { value: 1 },
|
|
59860
|
+
linewidth: { value: 1 },
|
|
59861
|
+
resolution: { value: new Vector2( 1, 1 ) },
|
|
59862
|
+
dashOffset: { value: 0 },
|
|
59863
|
+
dashScale: { value: 1 },
|
|
59864
|
+
dashSize: { value: 1 },
|
|
59865
|
+
gapSize: { value: 1 } // todo FIX - maybe change to totalSize
|
|
59866
|
+
|
|
59867
|
+
};
|
|
59868
|
+
|
|
59869
|
+
ShaderLib[ 'line' ] = {
|
|
59870
|
+
|
|
59871
|
+
uniforms: UniformsUtils.merge( [
|
|
59872
|
+
UniformsLib.common,
|
|
59873
|
+
UniformsLib.fog,
|
|
59874
|
+
UniformsLib.line
|
|
59875
|
+
] ),
|
|
59876
|
+
|
|
59877
|
+
vertexShader:
|
|
59878
|
+
/* glsl */`
|
|
59879
|
+
#include <common>
|
|
59880
|
+
#include <color_pars_vertex>
|
|
59881
|
+
#include <fog_pars_vertex>
|
|
59882
|
+
#include <logdepthbuf_pars_vertex>
|
|
59883
|
+
#include <clipping_planes_pars_vertex>
|
|
59884
|
+
|
|
59885
|
+
uniform float linewidth;
|
|
59886
|
+
uniform vec2 resolution;
|
|
59887
|
+
|
|
59888
|
+
attribute vec3 instanceStart;
|
|
59889
|
+
attribute vec3 instanceEnd;
|
|
59890
|
+
|
|
59891
|
+
attribute vec3 instanceColorStart;
|
|
59892
|
+
attribute vec3 instanceColorEnd;
|
|
59893
|
+
|
|
59894
|
+
#ifdef WORLD_UNITS
|
|
59895
|
+
|
|
59896
|
+
varying vec4 worldPos;
|
|
59897
|
+
varying vec3 worldStart;
|
|
59898
|
+
varying vec3 worldEnd;
|
|
59899
|
+
|
|
59900
|
+
#ifdef USE_DASH
|
|
59901
|
+
|
|
59902
|
+
varying vec2 vUv;
|
|
59903
|
+
|
|
59904
|
+
#endif
|
|
59905
|
+
|
|
59906
|
+
#else
|
|
59907
|
+
|
|
59908
|
+
varying vec2 vUv;
|
|
59909
|
+
|
|
59910
|
+
#endif
|
|
59911
|
+
|
|
59912
|
+
#ifdef USE_DASH
|
|
59913
|
+
|
|
59914
|
+
uniform float dashScale;
|
|
59915
|
+
attribute float instanceDistanceStart;
|
|
59916
|
+
attribute float instanceDistanceEnd;
|
|
59917
|
+
varying float vLineDistance;
|
|
59918
|
+
|
|
59919
|
+
#endif
|
|
59920
|
+
|
|
59921
|
+
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
59922
|
+
|
|
59923
|
+
// trim end segment so it terminates between the camera plane and the near plane
|
|
59924
|
+
|
|
59925
|
+
// conservative estimate of the near plane
|
|
59926
|
+
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
59927
|
+
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
59928
|
+
float nearEstimate = - 0.5 * b / a;
|
|
59929
|
+
|
|
59930
|
+
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
59931
|
+
|
|
59932
|
+
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
59933
|
+
|
|
59934
|
+
}
|
|
59935
|
+
|
|
59936
|
+
void main() {
|
|
59937
|
+
|
|
59938
|
+
#ifdef USE_COLOR
|
|
59939
|
+
|
|
59940
|
+
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
59941
|
+
|
|
59942
|
+
#endif
|
|
59943
|
+
|
|
59944
|
+
#ifdef USE_DASH
|
|
59945
|
+
|
|
59946
|
+
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
59947
|
+
vUv = uv;
|
|
59948
|
+
|
|
59949
|
+
#endif
|
|
59950
|
+
|
|
59951
|
+
float aspect = resolution.x / resolution.y;
|
|
59952
|
+
|
|
59953
|
+
// camera space
|
|
59954
|
+
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
59955
|
+
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
59956
|
+
|
|
59957
|
+
#ifdef WORLD_UNITS
|
|
59958
|
+
|
|
59959
|
+
worldStart = start.xyz;
|
|
59960
|
+
worldEnd = end.xyz;
|
|
59961
|
+
|
|
59962
|
+
#else
|
|
59963
|
+
|
|
59964
|
+
vUv = uv;
|
|
59965
|
+
|
|
59966
|
+
#endif
|
|
59967
|
+
|
|
59968
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
59969
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
59970
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
59971
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
59972
|
+
|
|
59973
|
+
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
59974
|
+
|
|
59975
|
+
if ( perspective ) {
|
|
59976
|
+
|
|
59977
|
+
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
59978
|
+
|
|
59979
|
+
trimSegment( start, end );
|
|
59980
|
+
|
|
59981
|
+
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
59982
|
+
|
|
59983
|
+
trimSegment( end, start );
|
|
59984
|
+
|
|
59985
|
+
}
|
|
59986
|
+
|
|
59987
|
+
}
|
|
59988
|
+
|
|
59989
|
+
// clip space
|
|
59990
|
+
vec4 clipStart = projectionMatrix * start;
|
|
59991
|
+
vec4 clipEnd = projectionMatrix * end;
|
|
59992
|
+
|
|
59993
|
+
// ndc space
|
|
59994
|
+
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
59995
|
+
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
59996
|
+
|
|
59997
|
+
// direction
|
|
59998
|
+
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
59999
|
+
|
|
60000
|
+
// account for clip-space aspect ratio
|
|
60001
|
+
dir.x *= aspect;
|
|
60002
|
+
dir = normalize( dir );
|
|
60003
|
+
|
|
60004
|
+
#ifdef WORLD_UNITS
|
|
60005
|
+
|
|
60006
|
+
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
60007
|
+
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
60008
|
+
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
60009
|
+
vec3 worldFwd = cross( worldDir, worldUp );
|
|
60010
|
+
worldPos = position.y < 0.5 ? start: end;
|
|
60011
|
+
|
|
60012
|
+
// height offset
|
|
60013
|
+
float hw = linewidth * 0.5;
|
|
60014
|
+
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
60015
|
+
|
|
60016
|
+
// don't extend the line if we're rendering dashes because we
|
|
60017
|
+
// won't be rendering the endcaps
|
|
60018
|
+
#ifndef USE_DASH
|
|
60019
|
+
|
|
60020
|
+
// cap extension
|
|
60021
|
+
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
60022
|
+
|
|
60023
|
+
// add width to the box
|
|
60024
|
+
worldPos.xyz += worldFwd * hw;
|
|
60025
|
+
|
|
60026
|
+
// endcaps
|
|
60027
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
60028
|
+
|
|
60029
|
+
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
60030
|
+
|
|
60031
|
+
}
|
|
60032
|
+
|
|
60033
|
+
#endif
|
|
60034
|
+
|
|
60035
|
+
// project the worldpos
|
|
60036
|
+
vec4 clip = projectionMatrix * worldPos;
|
|
60037
|
+
|
|
60038
|
+
// shift the depth of the projected points so the line
|
|
60039
|
+
// segments overlap neatly
|
|
60040
|
+
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
60041
|
+
clip.z = clipPose.z * clip.w;
|
|
60042
|
+
|
|
60043
|
+
#else
|
|
60044
|
+
|
|
60045
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
60046
|
+
// undo aspect ratio adjustment
|
|
60047
|
+
dir.x /= aspect;
|
|
60048
|
+
offset.x /= aspect;
|
|
60049
|
+
|
|
60050
|
+
// sign flip
|
|
60051
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
60052
|
+
|
|
60053
|
+
// endcaps
|
|
60054
|
+
if ( position.y < 0.0 ) {
|
|
60055
|
+
|
|
60056
|
+
offset += - dir;
|
|
60057
|
+
|
|
60058
|
+
} else if ( position.y > 1.0 ) {
|
|
60059
|
+
|
|
60060
|
+
offset += dir;
|
|
60061
|
+
|
|
60062
|
+
}
|
|
60063
|
+
|
|
60064
|
+
// adjust for linewidth
|
|
60065
|
+
offset *= linewidth;
|
|
60066
|
+
|
|
60067
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
60068
|
+
offset /= resolution.y;
|
|
60069
|
+
|
|
60070
|
+
// select end
|
|
60071
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
60072
|
+
|
|
60073
|
+
// back to clip space
|
|
60074
|
+
offset *= clip.w;
|
|
60075
|
+
|
|
60076
|
+
clip.xy += offset;
|
|
60077
|
+
|
|
60078
|
+
#endif
|
|
60079
|
+
|
|
60080
|
+
gl_Position = clip;
|
|
60081
|
+
|
|
60082
|
+
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
60083
|
+
|
|
60084
|
+
#include <logdepthbuf_vertex>
|
|
60085
|
+
#include <clipping_planes_vertex>
|
|
60086
|
+
#include <fog_vertex>
|
|
60087
|
+
|
|
60088
|
+
}
|
|
60089
|
+
`,
|
|
60090
|
+
|
|
60091
|
+
fragmentShader:
|
|
60092
|
+
/* glsl */`
|
|
60093
|
+
uniform vec3 diffuse;
|
|
60094
|
+
uniform float opacity;
|
|
60095
|
+
uniform float linewidth;
|
|
60096
|
+
|
|
60097
|
+
#ifdef USE_DASH
|
|
60098
|
+
|
|
60099
|
+
uniform float dashOffset;
|
|
60100
|
+
uniform float dashSize;
|
|
60101
|
+
uniform float gapSize;
|
|
60102
|
+
|
|
60103
|
+
#endif
|
|
60104
|
+
|
|
60105
|
+
varying float vLineDistance;
|
|
60106
|
+
|
|
60107
|
+
#ifdef WORLD_UNITS
|
|
60108
|
+
|
|
60109
|
+
varying vec4 worldPos;
|
|
60110
|
+
varying vec3 worldStart;
|
|
60111
|
+
varying vec3 worldEnd;
|
|
60112
|
+
|
|
60113
|
+
#ifdef USE_DASH
|
|
60114
|
+
|
|
60115
|
+
varying vec2 vUv;
|
|
60116
|
+
|
|
60117
|
+
#endif
|
|
60118
|
+
|
|
60119
|
+
#else
|
|
60120
|
+
|
|
60121
|
+
varying vec2 vUv;
|
|
60122
|
+
|
|
60123
|
+
#endif
|
|
60124
|
+
|
|
60125
|
+
#include <common>
|
|
60126
|
+
#include <color_pars_fragment>
|
|
60127
|
+
#include <fog_pars_fragment>
|
|
60128
|
+
#include <logdepthbuf_pars_fragment>
|
|
60129
|
+
#include <clipping_planes_pars_fragment>
|
|
60130
|
+
|
|
60131
|
+
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
60132
|
+
|
|
60133
|
+
float mua;
|
|
60134
|
+
float mub;
|
|
60135
|
+
|
|
60136
|
+
vec3 p13 = p1 - p3;
|
|
60137
|
+
vec3 p43 = p4 - p3;
|
|
60138
|
+
|
|
60139
|
+
vec3 p21 = p2 - p1;
|
|
60140
|
+
|
|
60141
|
+
float d1343 = dot( p13, p43 );
|
|
60142
|
+
float d4321 = dot( p43, p21 );
|
|
60143
|
+
float d1321 = dot( p13, p21 );
|
|
60144
|
+
float d4343 = dot( p43, p43 );
|
|
60145
|
+
float d2121 = dot( p21, p21 );
|
|
60146
|
+
|
|
60147
|
+
float denom = d2121 * d4343 - d4321 * d4321;
|
|
60148
|
+
|
|
60149
|
+
float numer = d1343 * d4321 - d1321 * d4343;
|
|
60150
|
+
|
|
60151
|
+
mua = numer / denom;
|
|
60152
|
+
mua = clamp( mua, 0.0, 1.0 );
|
|
60153
|
+
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
60154
|
+
mub = clamp( mub, 0.0, 1.0 );
|
|
60155
|
+
|
|
60156
|
+
return vec2( mua, mub );
|
|
60157
|
+
|
|
60158
|
+
}
|
|
60159
|
+
|
|
60160
|
+
void main() {
|
|
60161
|
+
|
|
60162
|
+
#include <clipping_planes_fragment>
|
|
60163
|
+
|
|
60164
|
+
#ifdef USE_DASH
|
|
60165
|
+
|
|
60166
|
+
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
60167
|
+
|
|
60168
|
+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
60169
|
+
|
|
60170
|
+
#endif
|
|
60171
|
+
|
|
60172
|
+
float alpha = opacity;
|
|
60173
|
+
|
|
60174
|
+
#ifdef WORLD_UNITS
|
|
60175
|
+
|
|
60176
|
+
// Find the closest points on the view ray and the line segment
|
|
60177
|
+
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
60178
|
+
vec3 lineDir = worldEnd - worldStart;
|
|
60179
|
+
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
60180
|
+
|
|
60181
|
+
vec3 p1 = worldStart + lineDir * params.x;
|
|
60182
|
+
vec3 p2 = rayEnd * params.y;
|
|
60183
|
+
vec3 delta = p1 - p2;
|
|
60184
|
+
float len = length( delta );
|
|
60185
|
+
float norm = len / linewidth;
|
|
60186
|
+
|
|
60187
|
+
#ifndef USE_DASH
|
|
60188
|
+
|
|
60189
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
60190
|
+
|
|
60191
|
+
float dnorm = fwidth( norm );
|
|
60192
|
+
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
60193
|
+
|
|
60194
|
+
#else
|
|
60195
|
+
|
|
60196
|
+
if ( norm > 0.5 ) {
|
|
60197
|
+
|
|
60198
|
+
discard;
|
|
60199
|
+
|
|
60200
|
+
}
|
|
60201
|
+
|
|
60202
|
+
#endif
|
|
60203
|
+
|
|
60204
|
+
#endif
|
|
60205
|
+
|
|
60206
|
+
#else
|
|
60207
|
+
|
|
60208
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
60209
|
+
|
|
60210
|
+
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
60211
|
+
float a = vUv.x;
|
|
60212
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
60213
|
+
float len2 = a * a + b * b;
|
|
60214
|
+
float dlen = fwidth( len2 );
|
|
60215
|
+
|
|
60216
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
60217
|
+
|
|
60218
|
+
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
60219
|
+
|
|
60220
|
+
}
|
|
60221
|
+
|
|
60222
|
+
#else
|
|
60223
|
+
|
|
60224
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
60225
|
+
|
|
60226
|
+
float a = vUv.x;
|
|
60227
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
60228
|
+
float len2 = a * a + b * b;
|
|
60229
|
+
|
|
60230
|
+
if ( len2 > 1.0 ) discard;
|
|
60231
|
+
|
|
60232
|
+
}
|
|
60233
|
+
|
|
60234
|
+
#endif
|
|
60235
|
+
|
|
60236
|
+
#endif
|
|
60237
|
+
|
|
60238
|
+
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
60239
|
+
|
|
60240
|
+
#include <logdepthbuf_fragment>
|
|
60241
|
+
#include <color_fragment>
|
|
60242
|
+
|
|
60243
|
+
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
60244
|
+
|
|
60245
|
+
#include <tonemapping_fragment>
|
|
60246
|
+
#include <colorspace_fragment>
|
|
60247
|
+
#include <fog_fragment>
|
|
60248
|
+
#include <premultiplied_alpha_fragment>
|
|
60249
|
+
|
|
60250
|
+
}
|
|
60251
|
+
`
|
|
60252
|
+
};
|
|
60253
|
+
|
|
60254
|
+
class LineMaterial extends ShaderMaterial {
|
|
60255
|
+
|
|
60256
|
+
|
|
60257
|
+
static get type() {
|
|
60258
|
+
|
|
60259
|
+
return 'LineMaterial';
|
|
60260
|
+
|
|
60261
|
+
}
|
|
60262
|
+
|
|
60263
|
+
constructor( parameters ) {
|
|
60264
|
+
|
|
60265
|
+
super( {
|
|
60266
|
+
|
|
60267
|
+
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
|
|
60268
|
+
|
|
60269
|
+
vertexShader: ShaderLib[ 'line' ].vertexShader,
|
|
60270
|
+
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
|
|
60271
|
+
|
|
60272
|
+
clipping: true // required for clipping support
|
|
60273
|
+
|
|
60274
|
+
} );
|
|
60275
|
+
|
|
60276
|
+
this.isLineMaterial = true;
|
|
60277
|
+
|
|
60278
|
+
this.setValues( parameters );
|
|
60279
|
+
|
|
60280
|
+
}
|
|
60281
|
+
|
|
60282
|
+
get color() {
|
|
60283
|
+
|
|
60284
|
+
return this.uniforms.diffuse.value;
|
|
60285
|
+
|
|
60286
|
+
}
|
|
60287
|
+
|
|
60288
|
+
set color( value ) {
|
|
60289
|
+
|
|
60290
|
+
this.uniforms.diffuse.value = value;
|
|
60291
|
+
|
|
60292
|
+
}
|
|
60293
|
+
|
|
60294
|
+
get worldUnits() {
|
|
60295
|
+
|
|
60296
|
+
return 'WORLD_UNITS' in this.defines;
|
|
60297
|
+
|
|
60298
|
+
}
|
|
60299
|
+
|
|
60300
|
+
set worldUnits( value ) {
|
|
60301
|
+
|
|
60302
|
+
if ( value === true ) {
|
|
60303
|
+
|
|
60304
|
+
this.defines.WORLD_UNITS = '';
|
|
60305
|
+
|
|
60306
|
+
} else {
|
|
60307
|
+
|
|
60308
|
+
delete this.defines.WORLD_UNITS;
|
|
60309
|
+
|
|
60310
|
+
}
|
|
60311
|
+
|
|
60312
|
+
}
|
|
60313
|
+
|
|
60314
|
+
get linewidth() {
|
|
60315
|
+
|
|
60316
|
+
return this.uniforms.linewidth.value;
|
|
60317
|
+
|
|
60318
|
+
}
|
|
60319
|
+
|
|
60320
|
+
set linewidth( value ) {
|
|
60321
|
+
|
|
60322
|
+
if ( ! this.uniforms.linewidth ) return;
|
|
60323
|
+
this.uniforms.linewidth.value = value;
|
|
60324
|
+
|
|
60325
|
+
}
|
|
60326
|
+
|
|
60327
|
+
get dashed() {
|
|
60328
|
+
|
|
60329
|
+
return 'USE_DASH' in this.defines;
|
|
60330
|
+
|
|
60331
|
+
}
|
|
60332
|
+
|
|
60333
|
+
set dashed( value ) {
|
|
60334
|
+
|
|
60335
|
+
if ( ( value === true ) !== this.dashed ) {
|
|
60336
|
+
|
|
60337
|
+
this.needsUpdate = true;
|
|
60338
|
+
|
|
60339
|
+
}
|
|
60340
|
+
|
|
60341
|
+
if ( value === true ) {
|
|
60342
|
+
|
|
60343
|
+
this.defines.USE_DASH = '';
|
|
60344
|
+
|
|
60345
|
+
} else {
|
|
60346
|
+
|
|
60347
|
+
delete this.defines.USE_DASH;
|
|
60348
|
+
|
|
60349
|
+
}
|
|
60350
|
+
|
|
60351
|
+
}
|
|
60352
|
+
|
|
60353
|
+
get dashScale() {
|
|
60354
|
+
|
|
60355
|
+
return this.uniforms.dashScale.value;
|
|
60356
|
+
|
|
60357
|
+
}
|
|
60358
|
+
|
|
60359
|
+
set dashScale( value ) {
|
|
60360
|
+
|
|
60361
|
+
this.uniforms.dashScale.value = value;
|
|
60362
|
+
|
|
60363
|
+
}
|
|
60364
|
+
|
|
60365
|
+
get dashSize() {
|
|
60366
|
+
|
|
60367
|
+
return this.uniforms.dashSize.value;
|
|
60368
|
+
|
|
60369
|
+
}
|
|
60370
|
+
|
|
60371
|
+
set dashSize( value ) {
|
|
60372
|
+
|
|
60373
|
+
this.uniforms.dashSize.value = value;
|
|
60374
|
+
|
|
60375
|
+
}
|
|
60376
|
+
|
|
60377
|
+
get dashOffset() {
|
|
60378
|
+
|
|
60379
|
+
return this.uniforms.dashOffset.value;
|
|
60380
|
+
|
|
60381
|
+
}
|
|
60382
|
+
|
|
60383
|
+
set dashOffset( value ) {
|
|
60384
|
+
|
|
60385
|
+
this.uniforms.dashOffset.value = value;
|
|
60386
|
+
|
|
60387
|
+
}
|
|
60388
|
+
|
|
60389
|
+
get gapSize() {
|
|
60390
|
+
|
|
60391
|
+
return this.uniforms.gapSize.value;
|
|
60392
|
+
|
|
60393
|
+
}
|
|
60394
|
+
|
|
60395
|
+
set gapSize( value ) {
|
|
60396
|
+
|
|
60397
|
+
this.uniforms.gapSize.value = value;
|
|
60398
|
+
|
|
60399
|
+
}
|
|
60400
|
+
|
|
60401
|
+
get opacity() {
|
|
60402
|
+
|
|
60403
|
+
return this.uniforms.opacity.value;
|
|
60404
|
+
|
|
60405
|
+
}
|
|
60406
|
+
|
|
60407
|
+
set opacity( value ) {
|
|
60408
|
+
|
|
60409
|
+
if ( ! this.uniforms ) return;
|
|
60410
|
+
this.uniforms.opacity.value = value;
|
|
60411
|
+
|
|
60412
|
+
}
|
|
60413
|
+
|
|
60414
|
+
get resolution() {
|
|
60415
|
+
|
|
60416
|
+
return this.uniforms.resolution.value;
|
|
60417
|
+
|
|
60418
|
+
}
|
|
60419
|
+
|
|
60420
|
+
set resolution( value ) {
|
|
60421
|
+
|
|
60422
|
+
this.uniforms.resolution.value.copy( value );
|
|
60423
|
+
|
|
60424
|
+
}
|
|
60425
|
+
|
|
60426
|
+
get alphaToCoverage() {
|
|
60427
|
+
|
|
60428
|
+
return 'USE_ALPHA_TO_COVERAGE' in this.defines;
|
|
60429
|
+
|
|
60430
|
+
}
|
|
60431
|
+
|
|
60432
|
+
set alphaToCoverage( value ) {
|
|
60433
|
+
|
|
60434
|
+
if ( ! this.defines ) return;
|
|
60435
|
+
|
|
60436
|
+
if ( ( value === true ) !== this.alphaToCoverage ) {
|
|
60437
|
+
|
|
60438
|
+
this.needsUpdate = true;
|
|
60439
|
+
|
|
60440
|
+
}
|
|
60441
|
+
|
|
60442
|
+
if ( value === true ) {
|
|
60443
|
+
|
|
60444
|
+
this.defines.USE_ALPHA_TO_COVERAGE = '';
|
|
60445
|
+
|
|
60446
|
+
} else {
|
|
60447
|
+
|
|
60448
|
+
delete this.defines.USE_ALPHA_TO_COVERAGE;
|
|
60449
|
+
|
|
60450
|
+
}
|
|
60451
|
+
|
|
60452
|
+
}
|
|
60453
|
+
|
|
60454
|
+
}
|
|
60455
|
+
|
|
60456
|
+
const _viewport = new Vector4();
|
|
60457
|
+
|
|
60458
|
+
const _start = new Vector3();
|
|
60459
|
+
const _end = new Vector3();
|
|
60460
|
+
|
|
60461
|
+
const _start4 = new Vector4();
|
|
60462
|
+
const _end4 = new Vector4();
|
|
60463
|
+
|
|
60464
|
+
const _ssOrigin = new Vector4();
|
|
60465
|
+
const _ssOrigin3 = new Vector3();
|
|
60466
|
+
const _mvMatrix = new Matrix4();
|
|
60467
|
+
const _line = new Line3();
|
|
60468
|
+
const _closestPoint = new Vector3();
|
|
60469
|
+
|
|
60470
|
+
const _box = new Box3();
|
|
60471
|
+
const _sphere = new Sphere();
|
|
60472
|
+
const _clipToWorldVector = new Vector4();
|
|
60473
|
+
|
|
60474
|
+
let _ray, _lineWidth;
|
|
60475
|
+
|
|
60476
|
+
// Returns the margin required to expand by in world space given the distance from the camera,
|
|
60477
|
+
// line width, resolution, and camera projection
|
|
60478
|
+
function getWorldSpaceHalfWidth( camera, distance, resolution ) {
|
|
60479
|
+
|
|
60480
|
+
// transform into clip space, adjust the x and y values by the pixel width offset, then
|
|
60481
|
+
// transform back into world space to get world offset. Note clip space is [-1, 1] so full
|
|
60482
|
+
// width does not need to be halved.
|
|
60483
|
+
_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );
|
|
60484
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
60485
|
+
_clipToWorldVector.x = _lineWidth / resolution.width;
|
|
60486
|
+
_clipToWorldVector.y = _lineWidth / resolution.height;
|
|
60487
|
+
_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );
|
|
60488
|
+
_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
|
|
60489
|
+
|
|
60490
|
+
return Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );
|
|
60491
|
+
|
|
60492
|
+
}
|
|
60493
|
+
|
|
60494
|
+
function raycastWorldUnits( lineSegments, intersects ) {
|
|
60495
|
+
|
|
60496
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
60497
|
+
const geometry = lineSegments.geometry;
|
|
60498
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
60499
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
60500
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
60501
|
+
|
|
60502
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
60503
|
+
|
|
60504
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
60505
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
60506
|
+
|
|
60507
|
+
_line.applyMatrix4( matrixWorld );
|
|
60508
|
+
|
|
60509
|
+
const pointOnLine = new Vector3();
|
|
60510
|
+
const point = new Vector3();
|
|
60511
|
+
|
|
60512
|
+
_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
60513
|
+
const isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;
|
|
60514
|
+
|
|
60515
|
+
if ( isInside ) {
|
|
60516
|
+
|
|
60517
|
+
intersects.push( {
|
|
60518
|
+
point,
|
|
60519
|
+
pointOnLine,
|
|
60520
|
+
distance: _ray.origin.distanceTo( point ),
|
|
60521
|
+
object: lineSegments,
|
|
60522
|
+
face: null,
|
|
60523
|
+
faceIndex: i,
|
|
60524
|
+
uv: null,
|
|
60525
|
+
uv1: null,
|
|
60526
|
+
} );
|
|
60527
|
+
|
|
60528
|
+
}
|
|
60529
|
+
|
|
60530
|
+
}
|
|
60531
|
+
|
|
60532
|
+
}
|
|
60533
|
+
|
|
60534
|
+
function raycastScreenSpace( lineSegments, camera, intersects ) {
|
|
60535
|
+
|
|
60536
|
+
const projectionMatrix = camera.projectionMatrix;
|
|
60537
|
+
const material = lineSegments.material;
|
|
60538
|
+
const resolution = material.resolution;
|
|
60539
|
+
const matrixWorld = lineSegments.matrixWorld;
|
|
60540
|
+
|
|
60541
|
+
const geometry = lineSegments.geometry;
|
|
60542
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
60543
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
60544
|
+
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
|
|
60545
|
+
|
|
60546
|
+
const near = - camera.near;
|
|
60547
|
+
|
|
60548
|
+
//
|
|
60549
|
+
|
|
60550
|
+
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
60551
|
+
// sitting at the camera origin which will cause "w" to be 0 when
|
|
60552
|
+
// applying the projection matrix.
|
|
60553
|
+
_ray.at( 1, _ssOrigin );
|
|
60554
|
+
|
|
60555
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
60556
|
+
_ssOrigin.w = 1;
|
|
60557
|
+
_ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
|
60558
|
+
_ssOrigin.applyMatrix4( projectionMatrix );
|
|
60559
|
+
_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );
|
|
60560
|
+
|
|
60561
|
+
// screen space
|
|
60562
|
+
_ssOrigin.x *= resolution.x / 2;
|
|
60563
|
+
_ssOrigin.y *= resolution.y / 2;
|
|
60564
|
+
_ssOrigin.z = 0;
|
|
60565
|
+
|
|
60566
|
+
_ssOrigin3.copy( _ssOrigin );
|
|
60567
|
+
|
|
60568
|
+
_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
|
60569
|
+
|
|
60570
|
+
for ( let i = 0, l = segmentCount; i < l; i ++ ) {
|
|
60571
|
+
|
|
60572
|
+
_start4.fromBufferAttribute( instanceStart, i );
|
|
60573
|
+
_end4.fromBufferAttribute( instanceEnd, i );
|
|
60574
|
+
|
|
60575
|
+
_start4.w = 1;
|
|
60576
|
+
_end4.w = 1;
|
|
60577
|
+
|
|
60578
|
+
// camera space
|
|
60579
|
+
_start4.applyMatrix4( _mvMatrix );
|
|
60580
|
+
_end4.applyMatrix4( _mvMatrix );
|
|
60581
|
+
|
|
60582
|
+
// skip the segment if it's entirely behind the camera
|
|
60583
|
+
const isBehindCameraNear = _start4.z > near && _end4.z > near;
|
|
60584
|
+
if ( isBehindCameraNear ) {
|
|
60585
|
+
|
|
60586
|
+
continue;
|
|
60587
|
+
|
|
60588
|
+
}
|
|
60589
|
+
|
|
60590
|
+
// trim the segment if it extends behind camera near
|
|
60591
|
+
if ( _start4.z > near ) {
|
|
60592
|
+
|
|
60593
|
+
const deltaDist = _start4.z - _end4.z;
|
|
60594
|
+
const t = ( _start4.z - near ) / deltaDist;
|
|
60595
|
+
_start4.lerp( _end4, t );
|
|
60596
|
+
|
|
60597
|
+
} else if ( _end4.z > near ) {
|
|
60598
|
+
|
|
60599
|
+
const deltaDist = _end4.z - _start4.z;
|
|
60600
|
+
const t = ( _end4.z - near ) / deltaDist;
|
|
60601
|
+
_end4.lerp( _start4, t );
|
|
60602
|
+
|
|
60603
|
+
}
|
|
60604
|
+
|
|
60605
|
+
// clip space
|
|
60606
|
+
_start4.applyMatrix4( projectionMatrix );
|
|
60607
|
+
_end4.applyMatrix4( projectionMatrix );
|
|
60608
|
+
|
|
60609
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
60610
|
+
_start4.multiplyScalar( 1 / _start4.w );
|
|
60611
|
+
_end4.multiplyScalar( 1 / _end4.w );
|
|
60612
|
+
|
|
60613
|
+
// screen space
|
|
60614
|
+
_start4.x *= resolution.x / 2;
|
|
60615
|
+
_start4.y *= resolution.y / 2;
|
|
60616
|
+
|
|
60617
|
+
_end4.x *= resolution.x / 2;
|
|
60618
|
+
_end4.y *= resolution.y / 2;
|
|
60619
|
+
|
|
60620
|
+
// create 2d segment
|
|
60621
|
+
_line.start.copy( _start4 );
|
|
60622
|
+
_line.start.z = 0;
|
|
60623
|
+
|
|
60624
|
+
_line.end.copy( _end4 );
|
|
60625
|
+
_line.end.z = 0;
|
|
60626
|
+
|
|
60627
|
+
// get closest point on ray to segment
|
|
60628
|
+
const param = _line.closestPointToPointParameter( _ssOrigin3, true );
|
|
60629
|
+
_line.at( param, _closestPoint );
|
|
60630
|
+
|
|
60631
|
+
// check if the intersection point is within clip space
|
|
60632
|
+
const zPos = MathUtils.lerp( _start4.z, _end4.z, param );
|
|
60633
|
+
const isInClipSpace = zPos >= - 1 && zPos <= 1;
|
|
60634
|
+
|
|
60635
|
+
const isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;
|
|
60636
|
+
|
|
60637
|
+
if ( isInClipSpace && isInside ) {
|
|
60638
|
+
|
|
60639
|
+
_line.start.fromBufferAttribute( instanceStart, i );
|
|
60640
|
+
_line.end.fromBufferAttribute( instanceEnd, i );
|
|
60641
|
+
|
|
60642
|
+
_line.start.applyMatrix4( matrixWorld );
|
|
60643
|
+
_line.end.applyMatrix4( matrixWorld );
|
|
60644
|
+
|
|
60645
|
+
const pointOnLine = new Vector3();
|
|
60646
|
+
const point = new Vector3();
|
|
60647
|
+
|
|
60648
|
+
_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
|
|
60649
|
+
|
|
60650
|
+
intersects.push( {
|
|
60651
|
+
point: point,
|
|
60652
|
+
pointOnLine: pointOnLine,
|
|
60653
|
+
distance: _ray.origin.distanceTo( point ),
|
|
60654
|
+
object: lineSegments,
|
|
60655
|
+
face: null,
|
|
60656
|
+
faceIndex: i,
|
|
60657
|
+
uv: null,
|
|
60658
|
+
uv1: null,
|
|
60659
|
+
} );
|
|
60660
|
+
|
|
60661
|
+
}
|
|
60662
|
+
|
|
60663
|
+
}
|
|
60664
|
+
|
|
60665
|
+
}
|
|
60666
|
+
|
|
60667
|
+
class LineSegments2 extends Mesh {
|
|
60668
|
+
|
|
60669
|
+
constructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
60670
|
+
|
|
60671
|
+
super( geometry, material );
|
|
60672
|
+
|
|
60673
|
+
this.isLineSegments2 = true;
|
|
60674
|
+
|
|
60675
|
+
this.type = 'LineSegments2';
|
|
60676
|
+
|
|
60677
|
+
}
|
|
60678
|
+
|
|
60679
|
+
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
60680
|
+
|
|
60681
|
+
computeLineDistances() {
|
|
60682
|
+
|
|
60683
|
+
const geometry = this.geometry;
|
|
60684
|
+
|
|
60685
|
+
const instanceStart = geometry.attributes.instanceStart;
|
|
60686
|
+
const instanceEnd = geometry.attributes.instanceEnd;
|
|
60687
|
+
const lineDistances = new Float32Array( 2 * instanceStart.count );
|
|
60688
|
+
|
|
60689
|
+
for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
|
|
60690
|
+
|
|
60691
|
+
_start.fromBufferAttribute( instanceStart, i );
|
|
60692
|
+
_end.fromBufferAttribute( instanceEnd, i );
|
|
60693
|
+
|
|
60694
|
+
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
|
60695
|
+
lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
|
|
60696
|
+
|
|
60697
|
+
}
|
|
60698
|
+
|
|
60699
|
+
const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
60700
|
+
|
|
60701
|
+
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
60702
|
+
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
60703
|
+
|
|
60704
|
+
return this;
|
|
60705
|
+
|
|
60706
|
+
}
|
|
60707
|
+
|
|
60708
|
+
raycast( raycaster, intersects ) {
|
|
60709
|
+
|
|
60710
|
+
const worldUnits = this.material.worldUnits;
|
|
60711
|
+
const camera = raycaster.camera;
|
|
60712
|
+
|
|
60713
|
+
if ( camera === null && ! worldUnits ) {
|
|
60714
|
+
|
|
60715
|
+
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );
|
|
60716
|
+
|
|
60717
|
+
}
|
|
60718
|
+
|
|
60719
|
+
const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
|
|
60720
|
+
|
|
60721
|
+
_ray = raycaster.ray;
|
|
60722
|
+
|
|
60723
|
+
const matrixWorld = this.matrixWorld;
|
|
60724
|
+
const geometry = this.geometry;
|
|
60725
|
+
const material = this.material;
|
|
60726
|
+
|
|
60727
|
+
_lineWidth = material.linewidth + threshold;
|
|
60728
|
+
|
|
60729
|
+
// check if we intersect the sphere bounds
|
|
60730
|
+
if ( geometry.boundingSphere === null ) {
|
|
60731
|
+
|
|
60732
|
+
geometry.computeBoundingSphere();
|
|
60733
|
+
|
|
60734
|
+
}
|
|
60735
|
+
|
|
60736
|
+
_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );
|
|
60737
|
+
|
|
60738
|
+
// increase the sphere bounds by the worst case line screen space width
|
|
60739
|
+
let sphereMargin;
|
|
60740
|
+
if ( worldUnits ) {
|
|
60741
|
+
|
|
60742
|
+
sphereMargin = _lineWidth * 0.5;
|
|
60743
|
+
|
|
60744
|
+
} else {
|
|
60745
|
+
|
|
60746
|
+
const distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray.origin ) );
|
|
60747
|
+
sphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );
|
|
60748
|
+
|
|
60749
|
+
}
|
|
60750
|
+
|
|
60751
|
+
_sphere.radius += sphereMargin;
|
|
60752
|
+
|
|
60753
|
+
if ( _ray.intersectsSphere( _sphere ) === false ) {
|
|
60754
|
+
|
|
60755
|
+
return;
|
|
60756
|
+
|
|
60757
|
+
}
|
|
60758
|
+
|
|
60759
|
+
// check if we intersect the box bounds
|
|
60760
|
+
if ( geometry.boundingBox === null ) {
|
|
60761
|
+
|
|
60762
|
+
geometry.computeBoundingBox();
|
|
60763
|
+
|
|
60764
|
+
}
|
|
60765
|
+
|
|
60766
|
+
_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );
|
|
60767
|
+
|
|
60768
|
+
// increase the box bounds by the worst case line width
|
|
60769
|
+
let boxMargin;
|
|
60770
|
+
if ( worldUnits ) {
|
|
60771
|
+
|
|
60772
|
+
boxMargin = _lineWidth * 0.5;
|
|
60773
|
+
|
|
60774
|
+
} else {
|
|
60775
|
+
|
|
60776
|
+
const distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray.origin ) );
|
|
60777
|
+
boxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );
|
|
60778
|
+
|
|
60779
|
+
}
|
|
60780
|
+
|
|
60781
|
+
_box.expandByScalar( boxMargin );
|
|
60782
|
+
|
|
60783
|
+
if ( _ray.intersectsBox( _box ) === false ) {
|
|
60784
|
+
|
|
60785
|
+
return;
|
|
60786
|
+
|
|
60787
|
+
}
|
|
60788
|
+
|
|
60789
|
+
if ( worldUnits ) {
|
|
60790
|
+
|
|
60791
|
+
raycastWorldUnits( this, intersects );
|
|
60792
|
+
|
|
60793
|
+
} else {
|
|
60794
|
+
|
|
60795
|
+
raycastScreenSpace( this, camera, intersects );
|
|
60796
|
+
|
|
60797
|
+
}
|
|
60798
|
+
|
|
60799
|
+
}
|
|
60800
|
+
|
|
60801
|
+
onBeforeRender( renderer ) {
|
|
60802
|
+
|
|
60803
|
+
const uniforms = this.material.uniforms;
|
|
60804
|
+
|
|
60805
|
+
if ( uniforms && uniforms.resolution ) {
|
|
60806
|
+
|
|
60807
|
+
renderer.getViewport( _viewport );
|
|
60808
|
+
this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
|
|
60809
|
+
|
|
60810
|
+
}
|
|
60811
|
+
|
|
60812
|
+
}
|
|
60813
|
+
|
|
60814
|
+
}
|
|
60815
|
+
|
|
60816
|
+
class LineGeometry extends LineSegmentsGeometry {
|
|
60817
|
+
|
|
60818
|
+
constructor() {
|
|
60819
|
+
|
|
60820
|
+
super();
|
|
60821
|
+
|
|
60822
|
+
this.isLineGeometry = true;
|
|
60823
|
+
|
|
60824
|
+
this.type = 'LineGeometry';
|
|
60825
|
+
|
|
60826
|
+
}
|
|
60827
|
+
|
|
60828
|
+
setPositions( array ) {
|
|
60829
|
+
|
|
60830
|
+
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
|
|
60831
|
+
|
|
60832
|
+
const length = array.length - 3;
|
|
60833
|
+
const points = new Float32Array( 2 * length );
|
|
60834
|
+
|
|
60835
|
+
for ( let i = 0; i < length; i += 3 ) {
|
|
60836
|
+
|
|
60837
|
+
points[ 2 * i ] = array[ i ];
|
|
60838
|
+
points[ 2 * i + 1 ] = array[ i + 1 ];
|
|
60839
|
+
points[ 2 * i + 2 ] = array[ i + 2 ];
|
|
60840
|
+
|
|
60841
|
+
points[ 2 * i + 3 ] = array[ i + 3 ];
|
|
60842
|
+
points[ 2 * i + 4 ] = array[ i + 4 ];
|
|
60843
|
+
points[ 2 * i + 5 ] = array[ i + 5 ];
|
|
60844
|
+
|
|
60845
|
+
}
|
|
60846
|
+
|
|
60847
|
+
super.setPositions( points );
|
|
60848
|
+
|
|
60849
|
+
return this;
|
|
60850
|
+
|
|
60851
|
+
}
|
|
60852
|
+
|
|
60853
|
+
setColors( array ) {
|
|
60854
|
+
|
|
60855
|
+
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
|
|
60856
|
+
|
|
60857
|
+
const length = array.length - 3;
|
|
60858
|
+
const colors = new Float32Array( 2 * length );
|
|
60859
|
+
|
|
60860
|
+
for ( let i = 0; i < length; i += 3 ) {
|
|
60861
|
+
|
|
60862
|
+
colors[ 2 * i ] = array[ i ];
|
|
60863
|
+
colors[ 2 * i + 1 ] = array[ i + 1 ];
|
|
60864
|
+
colors[ 2 * i + 2 ] = array[ i + 2 ];
|
|
60865
|
+
|
|
60866
|
+
colors[ 2 * i + 3 ] = array[ i + 3 ];
|
|
60867
|
+
colors[ 2 * i + 4 ] = array[ i + 4 ];
|
|
60868
|
+
colors[ 2 * i + 5 ] = array[ i + 5 ];
|
|
60869
|
+
|
|
60870
|
+
}
|
|
60871
|
+
|
|
60872
|
+
super.setColors( colors );
|
|
60873
|
+
|
|
60874
|
+
return this;
|
|
60875
|
+
|
|
60876
|
+
}
|
|
60877
|
+
|
|
60878
|
+
fromLine( line ) {
|
|
60879
|
+
|
|
60880
|
+
const geometry = line.geometry;
|
|
60881
|
+
|
|
60882
|
+
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
60883
|
+
|
|
60884
|
+
// set colors, maybe
|
|
60885
|
+
|
|
60886
|
+
return this;
|
|
60887
|
+
|
|
60888
|
+
}
|
|
60889
|
+
|
|
60890
|
+
}
|
|
60891
|
+
|
|
60892
|
+
class Line2 extends LineSegments2 {
|
|
60893
|
+
|
|
60894
|
+
constructor( geometry = new LineGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {
|
|
60895
|
+
|
|
60896
|
+
super( geometry, material );
|
|
60897
|
+
|
|
60898
|
+
this.isLine2 = true;
|
|
60899
|
+
|
|
60900
|
+
this.type = 'Line2';
|
|
60901
|
+
|
|
60902
|
+
}
|
|
60903
|
+
|
|
60904
|
+
}
|
|
60905
|
+
|
|
60906
|
+
/**
|
|
60907
|
+
* 把标注顶点(local)序列展平成 Line2 需要的 world [x,y,z, ...]。
|
|
60908
|
+
* 每个点 local→world,再沿 world 法线外移 epsilon,避免与模型表面 z-fighting。
|
|
60909
|
+
* closed 时把首点追加到末尾形成环。
|
|
60910
|
+
*/
|
|
60911
|
+
function flatten(verts, closed, epsilon, mesh) {
|
|
60912
|
+
const pts = [];
|
|
60913
|
+
const push = (v) => {
|
|
60914
|
+
const { p, n } = localVertexToWorld(v, mesh);
|
|
60915
|
+
pts.push(p.x + n.x * epsilon, p.y + n.y * epsilon, p.z + n.z * epsilon);
|
|
60916
|
+
};
|
|
60917
|
+
verts.forEach(push);
|
|
60918
|
+
if (closed && verts.length > 1)
|
|
60919
|
+
push(verts[0]);
|
|
60920
|
+
return pts;
|
|
60921
|
+
}
|
|
60922
|
+
function makeContourLine(verts, color, closed, container, epsilon, mesh) {
|
|
60923
|
+
const geo = new LineGeometry();
|
|
60924
|
+
const pos = flatten(verts, closed, epsilon, mesh);
|
|
60925
|
+
// Line2 至少需要 2 个点;不足时给一个退化占位,后续 update 会补上。
|
|
60926
|
+
geo.setPositions(pos.length >= 6 ? pos : [0, 0, 0, 0, 0, 0]);
|
|
60927
|
+
const mat = new LineMaterial({
|
|
60928
|
+
color: new Color$1(color).getHex(),
|
|
60929
|
+
linewidth: 3, // 像素宽(需 resolution 配合)
|
|
60930
|
+
});
|
|
60931
|
+
mat.resolution.set(container.clientWidth, container.clientHeight);
|
|
60932
|
+
const line = new Line2(geo, mat);
|
|
60933
|
+
line.computeLineDistances();
|
|
60934
|
+
line.renderOrder = 998;
|
|
60935
|
+
// 关键:Line2 的包围球停留在初始点,拖拽生长后真实几何会被错误剔除。
|
|
60936
|
+
// 关闭视锥剔除,保证线始终渲染。
|
|
60937
|
+
line.frustumCulled = false;
|
|
60938
|
+
return line;
|
|
60939
|
+
}
|
|
60940
|
+
function updateContourLine(line, verts, closed, epsilon, mesh) {
|
|
60941
|
+
const pos = flatten(verts, closed, epsilon, mesh);
|
|
60942
|
+
if (pos.length < 6)
|
|
60943
|
+
return; // Line2 需要 >=2 点
|
|
60944
|
+
// 关键:Line2 在原 geometry 上 setPositions 扩容后只渲染首段(已知坑)。
|
|
60945
|
+
// 改为每次重建一个新 LineGeometry 并替换,保证实例数正确、全段渲染。
|
|
60946
|
+
const geo = new LineGeometry();
|
|
60947
|
+
geo.setPositions(pos);
|
|
60948
|
+
const old = line.geometry;
|
|
60949
|
+
line.geometry = geo;
|
|
60950
|
+
old.dispose();
|
|
60951
|
+
line.computeLineDistances();
|
|
60952
|
+
}
|
|
60953
|
+
/** 改变已有 contour 线的颜色。 */
|
|
60954
|
+
function setContourColor(line, color) {
|
|
60955
|
+
line.material.color.set(color);
|
|
60956
|
+
}
|
|
60957
|
+
|
|
60958
|
+
/**
|
|
60959
|
+
* 从 BufferGeometry 的索引构建顶点邻接图,用于模式 B(测地线)的最短路径。
|
|
60960
|
+
* 顶点坐标按 local 存;传入的查询点需先转为 local(mesh.worldToLocal)。
|
|
60961
|
+
*
|
|
60962
|
+
* 说明:几何须为已索引(indexed)。modelLoader 用 mergeVertices 焊接重复顶点,
|
|
60963
|
+
* 保证同一表面位置共享顶点,邻接图才连通。
|
|
60964
|
+
*
|
|
60965
|
+
* 性能:O(V²) Dijkstra + O(V) 最近顶点查找。对几万顶点单次点击可接受;
|
|
60966
|
+
* 若过大可后续换二叉堆 + 空间网格加速(留作升级)。
|
|
60967
|
+
*/
|
|
60968
|
+
class MeshGraph {
|
|
60969
|
+
constructor(geometry) {
|
|
60970
|
+
this.adj = [];
|
|
60971
|
+
const pos = geometry.getAttribute("position");
|
|
60972
|
+
this.positions = pos.array;
|
|
60973
|
+
const nrm = geometry.getAttribute("normal");
|
|
60974
|
+
this.normals = nrm ? nrm.array : null;
|
|
60975
|
+
this.vertexCount = pos.count;
|
|
60976
|
+
for (let i = 0; i < this.vertexCount; i++)
|
|
60977
|
+
this.adj.push(new Set());
|
|
60978
|
+
const addEdge = (a, b) => {
|
|
60979
|
+
this.adj[a].add(b);
|
|
60980
|
+
this.adj[b].add(a);
|
|
60981
|
+
};
|
|
60982
|
+
const index = geometry.getIndex();
|
|
60983
|
+
if (index) {
|
|
60984
|
+
for (let i = 0; i < index.count; i += 3) {
|
|
60985
|
+
const a = index.getX(i);
|
|
60986
|
+
const b = index.getX(i + 1);
|
|
60987
|
+
const c = index.getX(i + 2);
|
|
60988
|
+
addEdge(a, b);
|
|
60989
|
+
addEdge(b, c);
|
|
60990
|
+
addEdge(c, a);
|
|
60991
|
+
}
|
|
60992
|
+
}
|
|
60993
|
+
else {
|
|
60994
|
+
// 非索引兜底(连通性差,仅避免崩溃)。
|
|
60995
|
+
for (let i = 0; i + 2 < this.vertexCount; i += 3) {
|
|
60996
|
+
addEdge(i, i + 1);
|
|
60997
|
+
addEdge(i + 1, i + 2);
|
|
60998
|
+
addEdge(i + 2, i);
|
|
60999
|
+
}
|
|
61000
|
+
}
|
|
61001
|
+
}
|
|
61002
|
+
px(i) {
|
|
61003
|
+
return this.positions[i * 3];
|
|
61004
|
+
}
|
|
61005
|
+
py(i) {
|
|
61006
|
+
return this.positions[i * 3 + 1];
|
|
61007
|
+
}
|
|
61008
|
+
pz(i) {
|
|
61009
|
+
return this.positions[i * 3 + 2];
|
|
61010
|
+
}
|
|
61011
|
+
/** 最近顶点(传入 local 坐标)。 */
|
|
61012
|
+
nearestVertex(localPoint) {
|
|
61013
|
+
let best = -1;
|
|
61014
|
+
let bestD = Infinity;
|
|
61015
|
+
for (let i = 0; i < this.vertexCount; i++) {
|
|
61016
|
+
const dx = this.px(i) - localPoint.x;
|
|
61017
|
+
const dy = this.py(i) - localPoint.y;
|
|
61018
|
+
const dz = this.pz(i) - localPoint.z;
|
|
61019
|
+
const d = dx * dx + dy * dy + dz * dz;
|
|
61020
|
+
if (d < bestD) {
|
|
61021
|
+
bestD = d;
|
|
61022
|
+
best = i;
|
|
61023
|
+
}
|
|
61024
|
+
}
|
|
61025
|
+
return best;
|
|
61026
|
+
}
|
|
61027
|
+
/**
|
|
61028
|
+
* 两顶点间最短路径(含端点的顶点索引序列)。二叉堆 Dijkstra,O(E log V)。
|
|
61029
|
+
* 不连通时返回 [start,end] 兜底。
|
|
61030
|
+
*/
|
|
61031
|
+
shortestPath(startV, endV) {
|
|
61032
|
+
if (startV === endV)
|
|
61033
|
+
return [startV];
|
|
61034
|
+
const dist = new Float64Array(this.vertexCount).fill(Infinity);
|
|
61035
|
+
const prev = new Int32Array(this.vertexCount).fill(-1);
|
|
61036
|
+
const done = new Uint8Array(this.vertexCount);
|
|
61037
|
+
dist[startV] = 0;
|
|
61038
|
+
const heap = new MinHeap();
|
|
61039
|
+
heap.push(startV, 0);
|
|
61040
|
+
while (heap.size > 0) {
|
|
61041
|
+
const u = heap.pop();
|
|
61042
|
+
if (done[u])
|
|
61043
|
+
continue;
|
|
61044
|
+
done[u] = 1;
|
|
61045
|
+
if (u === endV)
|
|
61046
|
+
break;
|
|
61047
|
+
const ud = dist[u];
|
|
61048
|
+
const ux = this.px(u);
|
|
61049
|
+
const uy = this.py(u);
|
|
61050
|
+
const uz = this.pz(u);
|
|
61051
|
+
for (const w of this.adj[u]) {
|
|
61052
|
+
if (done[w])
|
|
61053
|
+
continue;
|
|
61054
|
+
const dx = this.px(w) - ux;
|
|
61055
|
+
const dy = this.py(w) - uy;
|
|
61056
|
+
const dz = this.pz(w) - uz;
|
|
61057
|
+
const nd = ud + Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
61058
|
+
if (nd < dist[w]) {
|
|
61059
|
+
dist[w] = nd;
|
|
61060
|
+
prev[w] = u;
|
|
61061
|
+
heap.push(w, nd);
|
|
61062
|
+
}
|
|
61063
|
+
}
|
|
61064
|
+
}
|
|
61065
|
+
if (prev[endV] === -1 && startV !== endV)
|
|
61066
|
+
return [startV, endV];
|
|
61067
|
+
const path = [];
|
|
61068
|
+
for (let c = endV; c !== -1; c = prev[c]) {
|
|
61069
|
+
path.push(c);
|
|
61070
|
+
if (c === startV)
|
|
61071
|
+
break;
|
|
61072
|
+
}
|
|
61073
|
+
return path.reverse();
|
|
61074
|
+
}
|
|
61075
|
+
vertexWorld(i, matrixWorld) {
|
|
61076
|
+
return new Vector3(this.px(i), this.py(i), this.pz(i)).applyMatrix4(matrixWorld);
|
|
61077
|
+
}
|
|
61078
|
+
vertexNormalWorld(i, mesh) {
|
|
61079
|
+
const n = new Vector3(0, 0, 1);
|
|
61080
|
+
if (this.normals) {
|
|
61081
|
+
n.set(this.normals[i * 3], this.normals[i * 3 + 1], this.normals[i * 3 + 2]);
|
|
61082
|
+
}
|
|
61083
|
+
const nm = new Matrix3().getNormalMatrix(mesh.matrixWorld);
|
|
61084
|
+
return n.applyMatrix3(nm).normalize();
|
|
61085
|
+
}
|
|
61086
|
+
/** 顶点的 local 坐标 + local 法线(图几何即 local 空间)。 */
|
|
61087
|
+
vertexLocal(i) {
|
|
61088
|
+
return {
|
|
61089
|
+
x: this.px(i),
|
|
61090
|
+
y: this.py(i),
|
|
61091
|
+
z: this.pz(i),
|
|
61092
|
+
nx: this.normals ? this.normals[i * 3] : 0,
|
|
61093
|
+
ny: this.normals ? this.normals[i * 3 + 1] : 0,
|
|
61094
|
+
nz: this.normals ? this.normals[i * 3 + 2] : 1,
|
|
61095
|
+
faceIndex: -1,
|
|
61096
|
+
};
|
|
61097
|
+
}
|
|
61098
|
+
}
|
|
61099
|
+
/** 极简二叉最小堆(按 priority 排序,存顶点索引)。用于 Dijkstra。 */
|
|
61100
|
+
class MinHeap {
|
|
61101
|
+
constructor() {
|
|
61102
|
+
this.ids = [];
|
|
61103
|
+
this.prio = [];
|
|
61104
|
+
}
|
|
61105
|
+
get size() {
|
|
61106
|
+
return this.ids.length;
|
|
61107
|
+
}
|
|
61108
|
+
push(id, priority) {
|
|
61109
|
+
this.ids.push(id);
|
|
61110
|
+
this.prio.push(priority);
|
|
61111
|
+
let i = this.ids.length - 1;
|
|
61112
|
+
while (i > 0) {
|
|
61113
|
+
const parent = (i - 1) >> 1;
|
|
61114
|
+
if (this.prio[parent] <= this.prio[i])
|
|
61115
|
+
break;
|
|
61116
|
+
this.swap(i, parent);
|
|
61117
|
+
i = parent;
|
|
61118
|
+
}
|
|
61119
|
+
}
|
|
61120
|
+
pop() {
|
|
61121
|
+
const topId = this.ids[0];
|
|
61122
|
+
const lastId = this.ids.pop();
|
|
61123
|
+
const lastPrio = this.prio.pop();
|
|
61124
|
+
if (this.ids.length > 0) {
|
|
61125
|
+
this.ids[0] = lastId;
|
|
61126
|
+
this.prio[0] = lastPrio;
|
|
61127
|
+
let i = 0;
|
|
61128
|
+
const n = this.ids.length;
|
|
61129
|
+
for (;;) {
|
|
61130
|
+
const l = 2 * i + 1;
|
|
61131
|
+
const r = 2 * i + 2;
|
|
61132
|
+
let smallest = i;
|
|
61133
|
+
if (l < n && this.prio[l] < this.prio[smallest])
|
|
61134
|
+
smallest = l;
|
|
61135
|
+
if (r < n && this.prio[r] < this.prio[smallest])
|
|
61136
|
+
smallest = r;
|
|
61137
|
+
if (smallest === i)
|
|
61138
|
+
break;
|
|
61139
|
+
this.swap(i, smallest);
|
|
61140
|
+
i = smallest;
|
|
61141
|
+
}
|
|
61142
|
+
}
|
|
61143
|
+
return topId;
|
|
61144
|
+
}
|
|
61145
|
+
swap(a, b) {
|
|
61146
|
+
const ti = this.ids[a];
|
|
61147
|
+
this.ids[a] = this.ids[b];
|
|
61148
|
+
this.ids[b] = ti;
|
|
61149
|
+
const tp = this.prio[a];
|
|
61150
|
+
this.prio[a] = this.prio[b];
|
|
61151
|
+
this.prio[b] = tp;
|
|
61152
|
+
}
|
|
61153
|
+
}
|
|
61154
|
+
|
|
61155
|
+
/**
|
|
61156
|
+
* 模式 B(测地线)状态机:逐次点击锚点,相邻锚点之间用 MeshGraph 求最短路径,
|
|
61157
|
+
* 拼成一条贴合表面的折线。Enter 结束并可闭合(首尾再求一段)。
|
|
61158
|
+
*/
|
|
61159
|
+
class GeodesicContour {
|
|
61160
|
+
constructor(graph, mesh) {
|
|
61161
|
+
this.graph = graph;
|
|
61162
|
+
this.mesh = mesh;
|
|
61163
|
+
this.anchors = []; // 顶点索引
|
|
61164
|
+
this.segments = []; // 相邻锚点间路径(含端点)
|
|
61165
|
+
}
|
|
61166
|
+
/** 传入 local 命中点,snap 到最近顶点并对上一锚点求路径。 */
|
|
61167
|
+
addAnchor(localHitPoint) {
|
|
61168
|
+
const v = this.graph.nearestVertex(localHitPoint);
|
|
61169
|
+
if (this.anchors.length > 0) {
|
|
61170
|
+
const prev = this.anchors[this.anchors.length - 1];
|
|
61171
|
+
this.segments.push(this.graph.shortestPath(prev, v));
|
|
61172
|
+
}
|
|
61173
|
+
this.anchors.push(v);
|
|
61174
|
+
}
|
|
61175
|
+
get anchorCount() {
|
|
61176
|
+
return this.anchors.length;
|
|
61177
|
+
}
|
|
61178
|
+
/** 把所有路径顶点(world)+ 法线 拼成折线;closed 时补一段首尾路径。 */
|
|
61179
|
+
buildVertices(closed) {
|
|
61180
|
+
const segs = this.segments.slice();
|
|
61181
|
+
if (closed && this.anchors.length > 2) {
|
|
61182
|
+
segs.push(this.graph.shortestPath(this.anchors[this.anchors.length - 1], this.anchors[0]));
|
|
61183
|
+
}
|
|
61184
|
+
const idxPath = [];
|
|
61185
|
+
segs.forEach((s, si) => {
|
|
61186
|
+
const start = si === 0 ? 0 : 1; // 去重相邻段共享端点
|
|
61187
|
+
for (let k = start; k < s.length; k++)
|
|
61188
|
+
idxPath.push(s[k]);
|
|
61189
|
+
});
|
|
61190
|
+
if (idxPath.length === 0 && this.anchors.length === 1) {
|
|
61191
|
+
idxPath.push(this.anchors[0]);
|
|
61192
|
+
}
|
|
61193
|
+
// 图几何即 local 空间,直接产出 local 顶点(渲染时再派生 world)。
|
|
61194
|
+
return idxPath.map((i) => this.graph.vertexLocal(i));
|
|
61195
|
+
}
|
|
61196
|
+
}
|
|
61197
|
+
|
|
61198
|
+
/**
|
|
61199
|
+
* 标注数据模型 + 撤销栈 + 导出。纯数据,无 three / DOM 依赖。
|
|
61200
|
+
* 撤销只记录 add / remove 两类原子操作(满足"撤销最近添加 / 恢复删除")。
|
|
61201
|
+
* 通过 subscribe 通知 UI 与渲染层(后者据 list() 做场景对账)。
|
|
61202
|
+
*/
|
|
61203
|
+
class AnnotationStore {
|
|
61204
|
+
constructor() {
|
|
61205
|
+
this.items = [];
|
|
61206
|
+
this.undoStack = [];
|
|
61207
|
+
this.subs = new Set();
|
|
61208
|
+
}
|
|
61209
|
+
notify() {
|
|
61210
|
+
this.subs.forEach((f) => f());
|
|
61211
|
+
}
|
|
61212
|
+
subscribe(cb) {
|
|
61213
|
+
this.subs.add(cb);
|
|
61214
|
+
return () => this.subs.delete(cb);
|
|
61215
|
+
}
|
|
61216
|
+
add(a) {
|
|
61217
|
+
this.items.push(a);
|
|
61218
|
+
this.undoStack.push({ kind: "add", ann: a });
|
|
61219
|
+
this.notify();
|
|
61220
|
+
}
|
|
61221
|
+
remove(id) {
|
|
61222
|
+
const i = this.items.findIndex((x) => x.id === id);
|
|
61223
|
+
if (i < 0)
|
|
61224
|
+
return undefined;
|
|
61225
|
+
const [ann] = this.items.splice(i, 1);
|
|
61226
|
+
this.undoStack.push({ kind: "remove", ann });
|
|
61227
|
+
this.notify();
|
|
61228
|
+
return ann;
|
|
61229
|
+
}
|
|
61230
|
+
undo() {
|
|
61231
|
+
const op = this.undoStack.pop();
|
|
61232
|
+
if (!op)
|
|
61233
|
+
return;
|
|
61234
|
+
if (op.kind === "add") {
|
|
61235
|
+
const i = this.items.findIndex((x) => x.id === op.ann.id);
|
|
61236
|
+
if (i >= 0)
|
|
61237
|
+
this.items.splice(i, 1);
|
|
61238
|
+
}
|
|
61239
|
+
else {
|
|
61240
|
+
this.items.push(op.ann);
|
|
61241
|
+
}
|
|
61242
|
+
this.notify();
|
|
61243
|
+
}
|
|
61244
|
+
/** 清空,返回被清掉的项(供渲染层 dispose three 对象)。 */
|
|
61245
|
+
clear() {
|
|
61246
|
+
const old = this.items;
|
|
61247
|
+
this.items = [];
|
|
61248
|
+
this.undoStack = [];
|
|
61249
|
+
this.notify();
|
|
61250
|
+
return old;
|
|
61251
|
+
}
|
|
61252
|
+
list() {
|
|
61253
|
+
return this.items;
|
|
61254
|
+
}
|
|
61255
|
+
get(id) {
|
|
61256
|
+
return this.items.find((x) => x.id === id);
|
|
61257
|
+
}
|
|
61258
|
+
setLabel(id, label) {
|
|
61259
|
+
const a = this.get(id);
|
|
61260
|
+
if (a) {
|
|
61261
|
+
a.label = label;
|
|
61262
|
+
this.notify();
|
|
61263
|
+
}
|
|
61264
|
+
}
|
|
61265
|
+
setColor(id, color) {
|
|
61266
|
+
const a = this.get(id);
|
|
61267
|
+
if (a) {
|
|
61268
|
+
a.color = color;
|
|
61269
|
+
this.notify();
|
|
61270
|
+
}
|
|
61271
|
+
}
|
|
61272
|
+
toJSON(modelName, mesh, opts = {}) {
|
|
61273
|
+
var _a;
|
|
61274
|
+
const space = (_a = opts.space) !== null && _a !== void 0 ? _a : "local";
|
|
61275
|
+
const toPt = (v) => {
|
|
61276
|
+
let x = v.x, y = v.y, z = v.z;
|
|
61277
|
+
if (space === "world") {
|
|
61278
|
+
const p = new Vector3(v.x, v.y, v.z).applyMatrix4(mesh.matrixWorld);
|
|
61279
|
+
x = p.x;
|
|
61280
|
+
y = p.y;
|
|
61281
|
+
z = p.z;
|
|
61282
|
+
}
|
|
61283
|
+
return opts.includeNormals ? [x, y, z, v.nx, v.ny, v.nz] : [x, y, z];
|
|
61284
|
+
};
|
|
61285
|
+
return {
|
|
61286
|
+
model: modelName,
|
|
61287
|
+
exportedAt: new Date().toISOString(),
|
|
61288
|
+
space,
|
|
61289
|
+
annotations: this.items.map((a) => ({
|
|
61290
|
+
id: a.id,
|
|
61291
|
+
type: a.type,
|
|
61292
|
+
mode: a.mode,
|
|
61293
|
+
label: a.label,
|
|
61294
|
+
color: a.color,
|
|
61295
|
+
closed: a.closed,
|
|
61296
|
+
points: a.vertices.map(toPt),
|
|
61297
|
+
})),
|
|
61298
|
+
};
|
|
61299
|
+
}
|
|
61300
|
+
}
|
|
61301
|
+
|
|
61302
|
+
const LINE_W = 3;
|
|
61303
|
+
const LINE_W_SEL = 6;
|
|
61304
|
+
/**
|
|
61305
|
+
* 表面标注主控制器(Phase 4):navigate / freehand / geodesic / point 四模式,
|
|
61306
|
+
* Enter 闭合,数据交给 AnnotationStore 管理(多条带颜色标签、撤销/删除/清空、导出)。
|
|
61307
|
+
* 渲染层据 store.list() 做场景对账(reconcile),撤销/删除自动加/移 three 对象。
|
|
61308
|
+
*/
|
|
61309
|
+
class SurfaceAnnotator {
|
|
61310
|
+
constructor(opts) {
|
|
61311
|
+
var _a, _b;
|
|
61312
|
+
this.mode = "navigate";
|
|
61313
|
+
this.spaceHeld = false;
|
|
61314
|
+
this.pointerDown = false;
|
|
61315
|
+
this.store = new AnnotationStore();
|
|
61316
|
+
this.managed = new Set();
|
|
61317
|
+
this.seq = 0;
|
|
61318
|
+
this.selectedId = null;
|
|
61319
|
+
/** 窗口尺寸变化时更新所有 fat line 的像素分辨率,否则线宽会失真。 */
|
|
61320
|
+
this.onResize = () => {
|
|
61321
|
+
const w = this.o.container.clientWidth;
|
|
61322
|
+
const h = this.o.container.clientHeight;
|
|
61323
|
+
for (const a of this.store.list()) {
|
|
61324
|
+
if (a.type === "contour" && a.object3D) {
|
|
61325
|
+
const mat = a.object3D.material;
|
|
61326
|
+
mat.resolution.set(w, h);
|
|
61327
|
+
}
|
|
61328
|
+
}
|
|
61329
|
+
if (this.activeLine)
|
|
61330
|
+
(this.activeLine.material.resolution.set(w, h));
|
|
61331
|
+
if (this.activeGeoLine)
|
|
61332
|
+
(this.activeGeoLine.material.resolution.set(w, h));
|
|
61333
|
+
};
|
|
61334
|
+
this.onPointerDown = (e) => {
|
|
61335
|
+
if (this.spaceHeld)
|
|
61336
|
+
return;
|
|
61337
|
+
if (e.button !== 0)
|
|
61338
|
+
return; // 仅左键
|
|
61339
|
+
if (!this.insideContainer(e))
|
|
61340
|
+
return;
|
|
61341
|
+
this.pointerDown = true;
|
|
61342
|
+
if (this.mode === "point") {
|
|
61343
|
+
const h = this.hit(e);
|
|
61344
|
+
if (!h)
|
|
61345
|
+
return;
|
|
61346
|
+
const v = worldHitToLocalVertex(h, this.o.mesh);
|
|
61347
|
+
const marker = makePointMarker(v, this.o.mesh, this.pointColorVal, this.markerRadius);
|
|
61348
|
+
this.o.scene.add(marker);
|
|
61349
|
+
const ann = {
|
|
61350
|
+
id: this.nextId(),
|
|
61351
|
+
type: "points",
|
|
61352
|
+
mode: null,
|
|
61353
|
+
label: `Point ${this.seq}`,
|
|
61354
|
+
color: this.pointColorVal,
|
|
61355
|
+
closed: false,
|
|
61356
|
+
vertices: [v],
|
|
61357
|
+
object3D: marker,
|
|
61358
|
+
};
|
|
61359
|
+
this.store.add(ann);
|
|
61360
|
+
return;
|
|
61361
|
+
}
|
|
61362
|
+
if (this.mode === "freehand") {
|
|
61363
|
+
this.activeStroke = new StrokeContour(this.minGap, this.maxJump, this.o.mesh);
|
|
61364
|
+
this.activeStroke.begin();
|
|
61365
|
+
const h = this.hit(e);
|
|
61366
|
+
if (h)
|
|
61367
|
+
this.activeStroke.addSample(h);
|
|
61368
|
+
this.activeLine = makeContourLine(this.activeStroke.vertices, this.freehandColor, false, this.o.container, this.epsilon, this.o.mesh);
|
|
61369
|
+
this.o.scene.add(this.activeLine);
|
|
61370
|
+
return;
|
|
61371
|
+
}
|
|
61372
|
+
if (this.mode === "geodesic") {
|
|
61373
|
+
const h = this.hit(e);
|
|
61374
|
+
if (!h)
|
|
61375
|
+
return;
|
|
61376
|
+
if (!this.activeGeo) {
|
|
61377
|
+
this.activeGeo = new GeodesicContour(this.graph, this.o.mesh);
|
|
61378
|
+
}
|
|
61379
|
+
const local = this.o.mesh.worldToLocal(h.point.clone());
|
|
61380
|
+
this.activeGeo.addAnchor(local);
|
|
61381
|
+
const verts = this.activeGeo.buildVertices(false);
|
|
61382
|
+
if (!this.activeGeoLine) {
|
|
61383
|
+
this.activeGeoLine = makeContourLine(verts, this.geodesicColor, false, this.o.container, this.epsilon, this.o.mesh);
|
|
61384
|
+
this.o.scene.add(this.activeGeoLine);
|
|
61385
|
+
}
|
|
61386
|
+
else {
|
|
61387
|
+
updateContourLine(this.activeGeoLine, verts, false, this.epsilon, this.o.mesh);
|
|
61388
|
+
}
|
|
61389
|
+
}
|
|
61390
|
+
};
|
|
61391
|
+
this.onPointerMove = (e) => {
|
|
61392
|
+
if (this.spaceHeld)
|
|
61393
|
+
return;
|
|
61394
|
+
if (this.mode === "freehand" &&
|
|
61395
|
+
this.pointerDown &&
|
|
61396
|
+
this.activeStroke &&
|
|
61397
|
+
this.activeLine) {
|
|
61398
|
+
const h = this.hit(e);
|
|
61399
|
+
if (!h)
|
|
61400
|
+
return;
|
|
61401
|
+
this.activeStroke.addSample(h);
|
|
61402
|
+
updateContourLine(this.activeLine, this.activeStroke.vertices, false, this.epsilon, this.o.mesh);
|
|
61403
|
+
}
|
|
61404
|
+
};
|
|
61405
|
+
this.onPointerUp = () => {
|
|
61406
|
+
if (!this.pointerDown)
|
|
61407
|
+
return;
|
|
61408
|
+
this.pointerDown = false;
|
|
61409
|
+
if (this.activeStroke && this.activeLine) {
|
|
61410
|
+
const verts = this.activeStroke.end();
|
|
61411
|
+
if (verts.length >= 2) {
|
|
61412
|
+
const ann = {
|
|
61413
|
+
id: this.nextId(),
|
|
61414
|
+
type: "contour",
|
|
61415
|
+
mode: "freehand",
|
|
61416
|
+
label: `Contour ${this.seq}`,
|
|
61417
|
+
color: this.freehandColor,
|
|
61418
|
+
closed: false,
|
|
61419
|
+
vertices: verts,
|
|
61420
|
+
object3D: this.activeLine,
|
|
61421
|
+
};
|
|
61422
|
+
this.store.add(ann);
|
|
61423
|
+
this.lastFreehand = ann;
|
|
61424
|
+
}
|
|
61425
|
+
else {
|
|
61426
|
+
this.o.scene.remove(this.activeLine);
|
|
61427
|
+
}
|
|
61428
|
+
this.activeStroke = undefined;
|
|
61429
|
+
this.activeLine = undefined;
|
|
61430
|
+
}
|
|
61431
|
+
};
|
|
61432
|
+
this.onKeyDown = (e) => {
|
|
61433
|
+
if (this.isTypingTarget(e))
|
|
61434
|
+
return;
|
|
61435
|
+
if (e.code === "Space") {
|
|
61436
|
+
this.spaceHeld = true;
|
|
61437
|
+
this.applyCameraGating();
|
|
61438
|
+
return;
|
|
61439
|
+
}
|
|
61440
|
+
if (e.key === "Escape") {
|
|
61441
|
+
this.setMode("navigate");
|
|
61442
|
+
return;
|
|
61443
|
+
}
|
|
61444
|
+
if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
|
|
61445
|
+
e.preventDefault();
|
|
61446
|
+
this.undo();
|
|
61447
|
+
return;
|
|
61448
|
+
}
|
|
61449
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
61450
|
+
if (this.selectedId)
|
|
61451
|
+
this.deleteAnnotation(this.selectedId);
|
|
61452
|
+
return;
|
|
61453
|
+
}
|
|
61454
|
+
if (e.key === "Enter") {
|
|
61455
|
+
// 测地线进行中 → 结束并闭合;否则闭合最近一条自由手绘线。
|
|
61456
|
+
if (this.activeGeo)
|
|
61457
|
+
this.finishGeodesic();
|
|
61458
|
+
else
|
|
61459
|
+
this.closeLastContour();
|
|
61460
|
+
return;
|
|
61461
|
+
}
|
|
61462
|
+
if (e.key === "1")
|
|
61463
|
+
this.setMode("navigate");
|
|
61464
|
+
if (e.key === "2")
|
|
61465
|
+
this.setMode("freehand");
|
|
61466
|
+
if (e.key === "3")
|
|
61467
|
+
this.setMode("geodesic");
|
|
61468
|
+
if (e.key === "4")
|
|
61469
|
+
this.setMode("point");
|
|
61470
|
+
};
|
|
61471
|
+
this.onKeyUp = (e) => {
|
|
61472
|
+
if (e.code === "Space") {
|
|
61473
|
+
this.spaceHeld = false;
|
|
61474
|
+
this.applyCameraGating();
|
|
61475
|
+
}
|
|
61476
|
+
};
|
|
61477
|
+
this.o = opts;
|
|
61478
|
+
const meshGeo = opts.mesh.geometry;
|
|
61479
|
+
if (!meshGeo.getAttribute("normal"))
|
|
61480
|
+
meshGeo.computeVertexNormals(); // 渲染需要法线
|
|
61481
|
+
meshGeo.computeBoundingBox();
|
|
61482
|
+
const diag = (_a = opts.bboxDiagonal) !== null && _a !== void 0 ? _a : meshGeo.boundingBox.getSize(new Vector3()).length();
|
|
61483
|
+
this.markerRadius = (_b = opts.markerRadius) !== null && _b !== void 0 ? _b : diag * 0.006;
|
|
61484
|
+
this.epsilon = diag * 0.002;
|
|
61485
|
+
this.minGap = diag * 0.004;
|
|
61486
|
+
this.maxJump = diag * 0.05;
|
|
61487
|
+
// 测地线连通性:单独焊接一份"仅位置"的几何给 MeshGraph 用——
|
|
61488
|
+
// 不动被渲染的 mesh(保留其法线/UV/纹理)。仅位置可保证同表面位置的顶点
|
|
61489
|
+
// 被 mergeVertices 合并(否则逐面法线/UV 会阻止合并,图断裂 → 闭合穿模)。
|
|
61490
|
+
const posOnly = new BufferGeometry();
|
|
61491
|
+
posOnly.setAttribute("position", meshGeo.getAttribute("position").clone());
|
|
61492
|
+
const graphGeo = mergeVertices(posOnly);
|
|
61493
|
+
graphGeo.computeVertexNormals();
|
|
61494
|
+
this.graph = new MeshGraph(graphGeo);
|
|
61495
|
+
this.store.subscribe(() => this.reconcile());
|
|
61496
|
+
// 监听挂到 window 的捕获阶段(capture=true):在 copper 的 TrackballControls
|
|
61497
|
+
// 之前拿到每一个指针事件,避免它的 setPointerCapture / 事件路由导致拖拽中途丢 move。
|
|
61498
|
+
window.addEventListener("pointerdown", this.onPointerDown, true);
|
|
61499
|
+
window.addEventListener("pointermove", this.onPointerMove, true);
|
|
61500
|
+
window.addEventListener("pointerup", this.onPointerUp, true);
|
|
61501
|
+
window.addEventListener("keydown", this.onKeyDown);
|
|
61502
|
+
window.addEventListener("keyup", this.onKeyUp);
|
|
61503
|
+
window.addEventListener("resize", this.onResize);
|
|
61504
|
+
this.applyCameraGating();
|
|
61505
|
+
}
|
|
61506
|
+
get freehandColor() {
|
|
61507
|
+
var _a;
|
|
61508
|
+
return (_a = this.o.freehandColor) !== null && _a !== void 0 ? _a : "#e5006e";
|
|
61509
|
+
}
|
|
61510
|
+
get geodesicColor() {
|
|
61511
|
+
var _a;
|
|
61512
|
+
return (_a = this.o.geodesicColor) !== null && _a !== void 0 ? _a : "#ffa24e";
|
|
61513
|
+
}
|
|
61514
|
+
get pointColorVal() {
|
|
61515
|
+
var _a;
|
|
61516
|
+
return (_a = this.o.pointColor) !== null && _a !== void 0 ? _a : "#ffd166";
|
|
61517
|
+
}
|
|
61518
|
+
// ---- 对外 API(供 Vue 调用) ----
|
|
61519
|
+
getMode() {
|
|
61520
|
+
return this.mode;
|
|
61521
|
+
}
|
|
61522
|
+
setMode(m) {
|
|
61523
|
+
var _a, _b;
|
|
61524
|
+
this.mode = m;
|
|
61525
|
+
this.applyCameraGating();
|
|
61526
|
+
(_b = (_a = this.o).onModeChange) === null || _b === void 0 ? void 0 : _b.call(_a, m);
|
|
61527
|
+
}
|
|
61528
|
+
getStore() {
|
|
61529
|
+
return this.store;
|
|
61530
|
+
}
|
|
61531
|
+
/** 当前标注列表快照。 */
|
|
61532
|
+
getAnnotations() {
|
|
61533
|
+
return this.store.list();
|
|
61534
|
+
}
|
|
61535
|
+
undo() {
|
|
61536
|
+
this.store.undo();
|
|
61537
|
+
}
|
|
61538
|
+
clearAll() {
|
|
61539
|
+
const removed = this.store.clear();
|
|
61540
|
+
removed.forEach((a) => {
|
|
61541
|
+
if (a.object3D) {
|
|
61542
|
+
this.o.scene.remove(a.object3D);
|
|
61543
|
+
this.disposeObject(a.object3D);
|
|
61544
|
+
}
|
|
61545
|
+
});
|
|
61546
|
+
this.managed.clear();
|
|
61547
|
+
this.selectedId = null;
|
|
61548
|
+
}
|
|
61549
|
+
deleteAnnotation(id) {
|
|
61550
|
+
if (this.selectedId === id)
|
|
61551
|
+
this.selectedId = null;
|
|
61552
|
+
this.store.remove(id);
|
|
61553
|
+
}
|
|
61554
|
+
selectAnnotation(id) {
|
|
61555
|
+
this.selectedId = id;
|
|
61556
|
+
this.applySelection();
|
|
61557
|
+
}
|
|
61558
|
+
/** 颜色变更后重画对应 three 对象。 */
|
|
61559
|
+
refreshAnnotation(id) {
|
|
61560
|
+
const a = this.store.get(id);
|
|
61561
|
+
if (!a || !a.object3D)
|
|
61562
|
+
return;
|
|
61563
|
+
if (a.type === "contour") {
|
|
61564
|
+
setContourColor(a.object3D, a.color);
|
|
61565
|
+
}
|
|
61566
|
+
else {
|
|
61567
|
+
const m = a.object3D;
|
|
61568
|
+
m.material.color.set(a.color);
|
|
61569
|
+
}
|
|
61570
|
+
}
|
|
61571
|
+
exportJSON(modelName, opts) {
|
|
61572
|
+
return this.store.toJSON(modelName, this.o.mesh, opts);
|
|
61573
|
+
}
|
|
61574
|
+
// ---- 内部 ----
|
|
61575
|
+
applyCameraGating() {
|
|
61576
|
+
// 按住 Space 临时旋转优先;否则仅 navigate 模式开相机。
|
|
61577
|
+
this.o.controls.enabled = this.spaceHeld || this.mode === "navigate";
|
|
61578
|
+
}
|
|
61579
|
+
/** 据 store.list() 对账场景:补齐缺失对象、移除已删对象(不 dispose,留给撤销恢复)。 */
|
|
61580
|
+
reconcile() {
|
|
61581
|
+
var _a, _b;
|
|
61582
|
+
const present = new Set();
|
|
61583
|
+
for (const a of this.store.list())
|
|
61584
|
+
if (a.object3D)
|
|
61585
|
+
present.add(a.object3D);
|
|
61586
|
+
for (const o of this.managed) {
|
|
61587
|
+
if (!present.has(o))
|
|
61588
|
+
this.o.scene.remove(o);
|
|
61589
|
+
}
|
|
61590
|
+
for (const o of present) {
|
|
61591
|
+
if (!this.managed.has(o))
|
|
61592
|
+
this.o.scene.add(o);
|
|
61593
|
+
}
|
|
61594
|
+
this.managed = present;
|
|
61595
|
+
this.applySelection();
|
|
61596
|
+
(_b = (_a = this.o).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.store.list());
|
|
61597
|
+
}
|
|
61598
|
+
applySelection() {
|
|
61599
|
+
for (const a of this.store.list()) {
|
|
61600
|
+
if (!a.object3D)
|
|
61601
|
+
continue;
|
|
61602
|
+
const sel = a.id === this.selectedId;
|
|
61603
|
+
if (a.type === "contour") {
|
|
61604
|
+
const mat = a.object3D.material;
|
|
61605
|
+
mat.linewidth = sel ? LINE_W_SEL : LINE_W;
|
|
61606
|
+
}
|
|
61607
|
+
else {
|
|
61608
|
+
a.object3D.scale.setScalar(sel ? 1.6 : 1);
|
|
61609
|
+
}
|
|
61610
|
+
}
|
|
61611
|
+
}
|
|
61612
|
+
disposeObject(o) {
|
|
61613
|
+
var _a, _b, _c;
|
|
61614
|
+
const any = o;
|
|
61615
|
+
(_b = (_a = any.geometry) === null || _a === void 0 ? void 0 : _a.dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
61616
|
+
const mat = any.material;
|
|
61617
|
+
if (Array.isArray(mat))
|
|
61618
|
+
mat.forEach((m) => m.dispose());
|
|
61619
|
+
else
|
|
61620
|
+
(_c = mat === null || mat === void 0 ? void 0 : mat.dispose) === null || _c === void 0 ? void 0 : _c.call(mat);
|
|
61621
|
+
}
|
|
61622
|
+
nextId() {
|
|
61623
|
+
return "a" + ++this.seq;
|
|
61624
|
+
}
|
|
61625
|
+
hit(e) {
|
|
61626
|
+
return raycastSurface(this.o.camera, this.o.container, this.o.mesh, e.clientX, e.clientY);
|
|
61627
|
+
}
|
|
61628
|
+
/** 事件目标是否落在标注容器内(排除面板/页面其它区域的点击)。 */
|
|
61629
|
+
insideContainer(e) {
|
|
61630
|
+
const t = e.target;
|
|
61631
|
+
return !!t && this.o.container.contains(t);
|
|
61632
|
+
}
|
|
61633
|
+
closeLastContour() {
|
|
61634
|
+
const last = this.lastFreehand;
|
|
61635
|
+
if (!last || last.closed || last.vertices.length < 3 || !last.object3D)
|
|
61636
|
+
return;
|
|
61637
|
+
// 用测地线沿表面把末点连回首点,避免直线弦从模型内部"抄近路"被遮挡。
|
|
61638
|
+
const tail = last.vertices[last.vertices.length - 1];
|
|
61639
|
+
const head = last.vertices[0];
|
|
61640
|
+
const closing = this.surfacePathBetween(tail, head);
|
|
61641
|
+
last.vertices = last.vertices.concat(closing);
|
|
61642
|
+
last.closed = true;
|
|
61643
|
+
updateContourLine(last.object3D, last.vertices, true, this.epsilon, this.o.mesh);
|
|
61644
|
+
}
|
|
61645
|
+
/** 沿网格表面求 a→b 的测地路径(local 顶点),去掉与 a 重合的首点。a/b 已是 local。 */
|
|
61646
|
+
surfacePathBetween(a, b) {
|
|
61647
|
+
const va = this.graph.nearestVertex(new Vector3(a.x, a.y, a.z));
|
|
61648
|
+
const vb = this.graph.nearestVertex(new Vector3(b.x, b.y, b.z));
|
|
61649
|
+
const path = this.graph.shortestPath(va, vb);
|
|
61650
|
+
return path.slice(1).map((i) => this.graph.vertexLocal(i));
|
|
61651
|
+
}
|
|
61652
|
+
/** 结束当前测地线:闭合成环并落定为一条 contour。 */
|
|
61653
|
+
finishGeodesic() {
|
|
61654
|
+
if (!this.activeGeo || !this.activeGeoLine)
|
|
61655
|
+
return;
|
|
61656
|
+
const closed = this.activeGeo.anchorCount > 2;
|
|
61657
|
+
const verts = this.activeGeo.buildVertices(closed);
|
|
61658
|
+
if (verts.length >= 2) {
|
|
61659
|
+
updateContourLine(this.activeGeoLine, verts, closed, this.epsilon, this.o.mesh);
|
|
61660
|
+
const ann = {
|
|
61661
|
+
id: this.nextId(),
|
|
61662
|
+
type: "contour",
|
|
61663
|
+
mode: "geodesic",
|
|
61664
|
+
label: `Contour ${this.seq}`,
|
|
61665
|
+
color: this.geodesicColor,
|
|
61666
|
+
closed,
|
|
61667
|
+
vertices: verts,
|
|
61668
|
+
object3D: this.activeGeoLine,
|
|
61669
|
+
};
|
|
61670
|
+
this.store.add(ann);
|
|
61671
|
+
}
|
|
61672
|
+
else {
|
|
61673
|
+
this.o.scene.remove(this.activeGeoLine);
|
|
61674
|
+
}
|
|
61675
|
+
this.activeGeo = undefined;
|
|
61676
|
+
this.activeGeoLine = undefined;
|
|
61677
|
+
}
|
|
61678
|
+
isTypingTarget(e) {
|
|
61679
|
+
const t = e.target;
|
|
61680
|
+
if (!t)
|
|
61681
|
+
return false;
|
|
61682
|
+
const tag = t.tagName;
|
|
61683
|
+
return tag === "INPUT" || tag === "TEXTAREA" || t.isContentEditable;
|
|
61684
|
+
}
|
|
61685
|
+
dispose() {
|
|
61686
|
+
window.removeEventListener("pointerdown", this.onPointerDown, true);
|
|
61687
|
+
window.removeEventListener("pointermove", this.onPointerMove, true);
|
|
61688
|
+
window.removeEventListener("pointerup", this.onPointerUp, true);
|
|
61689
|
+
window.removeEventListener("keydown", this.onKeyDown);
|
|
61690
|
+
window.removeEventListener("keyup", this.onKeyUp);
|
|
61691
|
+
window.removeEventListener("resize", this.onResize);
|
|
61692
|
+
}
|
|
61693
|
+
}
|
|
61694
|
+
|
|
58884
61695
|
class copperScene extends baseScene {
|
|
58885
61696
|
// rayster pick
|
|
58886
61697
|
constructor(container, renderer, opt) {
|
|
@@ -58890,6 +61701,7 @@ class copperScene extends baseScene {
|
|
|
58890
61701
|
this.mixer = null;
|
|
58891
61702
|
this.playRate = 1.0;
|
|
58892
61703
|
this.modelReady = false;
|
|
61704
|
+
this.surfaceAnnotators = [];
|
|
58893
61705
|
if ((opt === null || opt === void 0 ? void 0 : opt.controls) === "trackball") {
|
|
58894
61706
|
this.controls = new TrackballControls(this.camera, this.renderer.domElement);
|
|
58895
61707
|
}
|
|
@@ -58965,53 +61777,45 @@ class copperScene extends baseScene {
|
|
|
58965
61777
|
console.log("An error happened: ", error);
|
|
58966
61778
|
});
|
|
58967
61779
|
}
|
|
58968
|
-
// loadOBJ(url: string, callback?: (mesh: THREE.Group) => void) {
|
|
58969
|
-
// objLoader.load(
|
|
58970
|
-
// url,
|
|
58971
|
-
// (obj) => {
|
|
58972
|
-
// obj.traverse((child) => {
|
|
58973
|
-
// if ((child as THREE.Mesh).isMesh) {
|
|
58974
|
-
// // (child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
|
|
58975
|
-
// // side: THREE.DoubleSide,
|
|
58976
|
-
// // color: 0xffffff,
|
|
58977
|
-
// // });
|
|
58978
|
-
// // ((child as THREE.Mesh).material as THREE.MeshPhongMaterial).color =
|
|
58979
|
-
// // new THREE.Color(0xffffff);
|
|
58980
|
-
// }
|
|
58981
|
-
// });
|
|
58982
|
-
// const box = new THREE.Box3().setFromObject(obj);
|
|
58983
|
-
// const size = box.getSize(new THREE.Vector3()).length();
|
|
58984
|
-
// const center = box.getCenter(new THREE.Vector3());
|
|
58985
|
-
// this.controls.maxDistance = size * 10;
|
|
58986
|
-
// obj.position.x += obj.position.x - center.x;
|
|
58987
|
-
// obj.position.y += obj.position.y - center.y;
|
|
58988
|
-
// obj.position.z += obj.position.z - center.z;
|
|
58989
|
-
// if (!this.cameraPositionFlag) {
|
|
58990
|
-
// this.camera.position.copy(center);
|
|
58991
|
-
// this.camera.position.x += size / 2.0;
|
|
58992
|
-
// this.camera.position.y += size / 5.0;
|
|
58993
|
-
// this.camera.position.z += size / 2.0;
|
|
58994
|
-
// this.camera.lookAt(center);
|
|
58995
|
-
// this.viewPoint = this.setViewPoint(
|
|
58996
|
-
// this.camera as THREE.PerspectiveCamera,
|
|
58997
|
-
// [center.x, center.y, center.z]
|
|
58998
|
-
// );
|
|
58999
|
-
// }
|
|
59000
|
-
// this.scene.add(obj);
|
|
59001
|
-
// !!callback && callback(obj);
|
|
59002
|
-
// }, // called when loading is in progresses
|
|
59003
|
-
// (xhr: any) => {
|
|
59004
|
-
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
59005
|
-
// },
|
|
59006
|
-
// // called when loading has errors
|
|
59007
|
-
// (error: any) => {
|
|
59008
|
-
// console.log("An error happened");
|
|
59009
|
-
// }
|
|
59010
|
-
// );
|
|
59011
|
-
// }
|
|
59012
61780
|
loadVtk(url) {
|
|
59013
61781
|
copperVtkLoader(url, this.scene, this.content);
|
|
59014
61782
|
}
|
|
61783
|
+
/**
|
|
61784
|
+
* 在给定模型表面创建标注器(画 contour / 放点 / 导出坐标)。
|
|
61785
|
+
* target 可为单个 Mesh,或 Group/Object3D(自动选顶点数最多的 mesh)。
|
|
61786
|
+
* 复用本 scene 的 camera / container / controls;几何非索引时内部自动焊接索引化。
|
|
61787
|
+
*/
|
|
61788
|
+
createSurfaceAnnotator(target, opts) {
|
|
61789
|
+
const mesh = this.pickAnnotatableMesh(target);
|
|
61790
|
+
if (!mesh)
|
|
61791
|
+
throw new Error("createSurfaceAnnotator: no mesh found in target");
|
|
61792
|
+
const annotator = new SurfaceAnnotator(Object.assign({ scene: this.scene, camera: this.camera, container: this.container, controls: this.controls, mesh }, (opts !== null && opts !== void 0 ? opts : {})));
|
|
61793
|
+
this.surfaceAnnotators.push(annotator);
|
|
61794
|
+
return annotator;
|
|
61795
|
+
}
|
|
61796
|
+
pickAnnotatableMesh(target) {
|
|
61797
|
+
if (target.isMesh)
|
|
61798
|
+
return target;
|
|
61799
|
+
let best = null;
|
|
61800
|
+
let bestCount = -1;
|
|
61801
|
+
target.traverse((c) => {
|
|
61802
|
+
var _a, _b;
|
|
61803
|
+
const m = c;
|
|
61804
|
+
if (m.isMesh) {
|
|
61805
|
+
const n = (_b = (_a = m.geometry.getAttribute("position")) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0;
|
|
61806
|
+
if (n > bestCount) {
|
|
61807
|
+
bestCount = n;
|
|
61808
|
+
best = m;
|
|
61809
|
+
}
|
|
61810
|
+
}
|
|
61811
|
+
});
|
|
61812
|
+
return best;
|
|
61813
|
+
}
|
|
61814
|
+
/** 释放本 scene 创建的所有标注器(移除事件监听与标注对象)。 */
|
|
61815
|
+
disposeSurfaceAnnotators() {
|
|
61816
|
+
this.surfaceAnnotators.forEach((a) => a.dispose());
|
|
61817
|
+
this.surfaceAnnotators = [];
|
|
61818
|
+
}
|
|
59015
61819
|
loadVtks(models) {
|
|
59016
61820
|
let count = 0;
|
|
59017
61821
|
let { vtkLoader } = copperMultipleVtk();
|
|
@@ -79866,7 +82670,7 @@ function evaluateElement(element, weights) {
|
|
|
79866
82670
|
}
|
|
79867
82671
|
|
|
79868
82672
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
79869
|
-
const REVISION = "v3.
|
|
82673
|
+
const REVISION = "v3.6.1-beta";
|
|
79870
82674
|
console.log(`%cCopper3D Visualisation %cBeta:${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
79871
82675
|
|
|
79872
|
-
export { AI_CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, CHANNEL_COLORS, CHANNEL_HEX_COLORS, CameraViewPoint, Copper3dTrackballControls, GaussianSmoother, MeshNodeTool, NrrdTools, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, removeGuiFolderChilden, rgbaToCss, rgbaToHex, setHDRFilePath, throttle };
|
|
82676
|
+
export { AI_CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, CHANNEL_COLORS, CHANNEL_HEX_COLORS, CameraViewPoint, Copper3dTrackballControls, GaussianSmoother, MeshNodeTool, NrrdTools, REVISION, SurfaceAnnotator, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, removeGuiFolderChilden, rgbaToCss, rgbaToHex, setHDRFilePath, throttle };
|