@@ -28,12 +28,15 @@ function SurfaceTrace(scene, surface, uid) {
28
28
this . surface = surface ;
29
29
this . data = null ;
30
30
this . showContour = [ false , false , false ] ;
31
+ this . contourStart = [ null , null , null ] ;
32
+ this . contourEnd = [ null , null , null ] ;
33
+ this . contourSize = [ 0 , 0 , 0 ] ;
31
34
this . minValues = [ Infinity , Infinity , Infinity ] ;
32
35
this . maxValues = [ - Infinity , - Infinity , - Infinity ] ;
33
36
this . dataScaleX = 1.0 ;
34
37
this . dataScaleY = 1.0 ;
35
38
this . refineData = true ;
36
- this . _interpolatedZ = false ;
39
+ this . objectOffset = [ 0 , 0 , 0 ] ;
37
40
}
38
41
39
42
var proto = SurfaceTrace . prototype ;
@@ -346,19 +349,54 @@ proto.refineCoords = function(coords) {
346
349
}
347
350
} ;
348
351
352
+ function insertIfNewLevel ( arr , newValue ) {
353
+ var found = false ;
354
+ for ( var k = 0 ; k < arr . length ; k ++ ) {
355
+ if ( newValue === arr [ k ] ) {
356
+ found = true ;
357
+ break ;
358
+ }
359
+ }
360
+ if ( found === false ) arr . push ( newValue ) ;
361
+ }
362
+
349
363
proto . setContourLevels = function ( ) {
350
- var nlevels = [ [ ] , [ ] , [ ] ] ;
364
+ var newLevels = [ [ ] , [ ] , [ ] ] ;
365
+ var useNewLevels = [ false , false , false ] ;
351
366
var needsUpdate = false ;
352
367
353
- for ( var i = 0 ; i < 3 ; ++ i ) {
368
+ var i , j , value ;
369
+
370
+ for ( i = 0 ; i < 3 ; ++ i ) {
354
371
if ( this . showContour [ i ] ) {
355
372
needsUpdate = true ;
356
- nlevels [ i ] = this . scene . contourLevels [ i ] ;
373
+
374
+ if (
375
+ this . contourSize [ i ] > 0 &&
376
+ this . contourStart [ i ] !== null &&
377
+ this . contourEnd [ i ] !== null &&
378
+ this . contourEnd [ i ] > this . contourStart [ i ]
379
+ ) {
380
+ useNewLevels [ i ] = true ;
381
+
382
+ for ( j = this . contourStart [ i ] ; j < this . contourEnd [ i ] ; j += this . contourSize [ i ] ) {
383
+ value = j * this . scene . dataScale [ i ] ;
384
+
385
+ insertIfNewLevel ( newLevels [ i ] , value ) ;
386
+ }
387
+ }
388
+
357
389
}
358
390
}
359
391
360
392
if ( needsUpdate ) {
361
- this . surface . update ( { levels : nlevels } ) ;
393
+ var allLevels = [ [ ] , [ ] , [ ] ] ;
394
+ for ( i = 0 ; i < 3 ; ++ i ) {
395
+ if ( this . showContour [ i ] ) {
396
+ allLevels [ i ] = useNewLevels [ i ] ? newLevels [ i ] : this . scene . contourLevels [ i ] ;
397
+ }
398
+ }
399
+ this . surface . update ( { levels : allLevels } ) ;
362
400
}
363
401
} ;
364
402
@@ -453,15 +491,15 @@ proto.update = function(data) {
453
491
}
454
492
455
493
for ( i = 0 ; i < 3 ; i ++ ) {
456
- data . _objectOffset [ i ] = 0.5 * ( this . minValues [ i ] + this . maxValues [ i ] ) ;
494
+ this . objectOffset [ i ] = 0.5 * ( this . minValues [ i ] + this . maxValues [ i ] ) ;
457
495
}
458
496
459
497
for ( i = 0 ; i < 3 ; i ++ ) {
460
498
for ( j = 0 ; j < xlen ; j ++ ) {
461
499
for ( k = 0 ; k < ylen ; k ++ ) {
462
500
v = rawCoords [ i ] [ j ] [ k ] ;
463
501
if ( v !== null && v !== undefined ) {
464
- rawCoords [ i ] [ j ] [ k ] -= data . _objectOffset [ i ] ;
502
+ rawCoords [ i ] [ j ] [ k ] -= this . objectOffset [ i ] ;
465
503
}
466
504
}
467
505
}
@@ -561,8 +599,16 @@ proto.update = function(data) {
561
599
surface . highlightTint [ i ] = params . contourTint [ i ] = 1 ;
562
600
}
563
601
params . contourWidth [ i ] = contourParams . width ;
602
+
603
+ this . contourStart [ i ] = contourParams . start ;
604
+ this . contourEnd [ i ] = contourParams . end ;
605
+ this . contourSize [ i ] = contourParams . size ;
564
606
} else {
565
607
this . showContour [ i ] = false ;
608
+
609
+ this . contourStart [ i ] = null ;
610
+ this . contourEnd [ i ] = null ;
611
+ this . contourSize [ i ] = 0 ;
566
612
}
567
613
568
614
if ( contourParams . highlight ) {
@@ -576,11 +622,7 @@ proto.update = function(data) {
576
622
params . vertexColor = true ;
577
623
}
578
624
579
- params . objectOffset = [
580
- data . _objectOffset [ 0 ] ,
581
- data . _objectOffset [ 1 ] ,
582
- data . _objectOffset [ 2 ]
583
- ] ;
625
+ params . objectOffset = this . objectOffset ;
584
626
585
627
params . coords = coords ;
586
628
surface . update ( params ) ;
0 commit comments