@@ -58,9 +58,9 @@ function VoxelCylinderShape() {
58
58
cylinderEcToRadialTangentUp : new Matrix3 ( ) ,
59
59
cylinderRenderRadiusMinMax : new Cartesian2 ( ) ,
60
60
cylinderRenderAngleMinMax : new Cartesian2 ( ) ,
61
- cylinderUvToShapeUvRadius : new Cartesian2 ( ) ,
62
- cylinderUvToShapeUvAngle : new Cartesian2 ( ) ,
63
- cylinderUvToShapeUvHeight : new Cartesian2 ( ) ,
61
+ cylinderLocalToShapeUvRadius : new Cartesian2 ( ) ,
62
+ cylinderLocalToShapeUvAngle : new Cartesian2 ( ) ,
63
+ cylinderLocalToShapeUvHeight : new Cartesian2 ( ) ,
64
64
cylinderShapeUvAngleRangeOrigin : 0.0 ,
65
65
} ;
66
66
@@ -360,29 +360,25 @@ VoxelCylinderShape.prototype.update = function (
360
360
let radialOffset = 1.0 ;
361
361
if ( radiusRange !== 0.0 ) {
362
362
radialScale = 1.0 / radiusRange ;
363
- radialOffset = - minBounds . x / radiusRange ;
363
+ radialOffset = - minBounds . x * radialScale ;
364
364
}
365
- shaderUniforms . cylinderUvToShapeUvRadius = Cartesian2 . fromElements (
365
+ shaderUniforms . cylinderLocalToShapeUvRadius = Cartesian2 . fromElements (
366
366
radialScale ,
367
367
radialOffset ,
368
- shaderUniforms . cylinderUvToShapeUvRadius ,
368
+ shaderUniforms . cylinderLocalToShapeUvRadius ,
369
369
) ;
370
370
371
371
const heightRange = maxBounds . z - minBounds . z ; // Default 2.0
372
372
let heightScale = 0.0 ;
373
373
let heightOffset = 1.0 ;
374
374
if ( heightRange !== 0.0 ) {
375
375
heightScale = 1.0 / heightRange ;
376
- // TODO: drop all this UV stuff. We are now using physical bounds in meters.
377
- // offset = -minHeightUv / (maxHeightUv - minHeightUv)
378
- // offset = -(minHeight * 0.5 + 0.5) / ((maxHeight * 0.5 + 0.5) - (minHeight * 0.5 + 0.5))
379
- // offset = -(minHeight + 1.0) / (maxHeight - minHeight)
380
- heightOffset = - ( minBounds . z + 1.0 ) / heightRange ;
376
+ heightOffset = - minBounds . z * heightScale ;
381
377
}
382
- shaderUniforms . cylinderUvToShapeUvHeight = Cartesian2 . fromElements (
378
+ shaderUniforms . cylinderLocalToShapeUvHeight = Cartesian2 . fromElements (
383
379
heightScale ,
384
380
heightOffset ,
385
- shaderUniforms . cylinderUvToShapeUvHeight ,
381
+ shaderUniforms . cylinderLocalToShapeUvHeight ,
386
382
) ;
387
383
388
384
if ( renderHasAngle ) {
@@ -416,19 +412,19 @@ VoxelCylinderShape.prototype.update = function (
416
412
shaderUniforms . cylinderShapeUvAngleRangeOrigin = uvAngleRangeOrigin ;
417
413
418
414
if ( shapeAngleRange <= epsilonAngle ) {
419
- shaderUniforms . cylinderUvToShapeUvAngle = Cartesian2 . fromElements (
415
+ shaderUniforms . cylinderLocalToShapeUvAngle = Cartesian2 . fromElements (
420
416
0.0 ,
421
417
1.0 ,
422
- shaderUniforms . cylinderUvToShapeUvAngle ,
418
+ shaderUniforms . cylinderLocalToShapeUvAngle ,
423
419
) ;
424
420
} else {
425
421
const scale = defaultAngleRange / shapeAngleRange ;
426
422
const shiftedMinAngle = uvMinAngle - uvAngleRangeOrigin ;
427
423
const offset = - scale * ( shiftedMinAngle - Math . floor ( shiftedMinAngle ) ) ;
428
- shaderUniforms . cylinderUvToShapeUvAngle = Cartesian2 . fromElements (
424
+ shaderUniforms . cylinderLocalToShapeUvAngle = Cartesian2 . fromElements (
429
425
scale ,
430
426
offset ,
431
- shaderUniforms . cylinderUvToShapeUvAngle ,
427
+ shaderUniforms . cylinderLocalToShapeUvAngle ,
432
428
) ;
433
429
}
434
430
@@ -512,48 +508,40 @@ function updateRtuTransform(shape, frameState) {
512
508
/**
513
509
* Convert a UV coordinate to the shape's UV space.
514
510
* @private
515
- * @param {Cartesian3 } positionUV The UV coordinate to convert.
511
+ * @param {Cartesian3 } positionLocal The local coordinate to convert.
516
512
* @param {Cartesian3 } result The Cartesian3 to store the result in.
517
513
* @returns {Cartesian3 } The converted UV coordinate.
518
514
*/
519
- VoxelCylinderShape . prototype . convertUvToShapeUvSpace = function (
520
- positionUV ,
515
+ VoxelCylinderShape . prototype . convertLocalToShapeUvSpace = function (
516
+ positionLocal ,
521
517
result ,
522
518
) {
523
519
//>>includeStart('debug', pragmas.debug);
524
- Check . typeOf . object ( "positionUV " , positionUV ) ;
520
+ Check . typeOf . object ( "positionLocal " , positionLocal ) ;
525
521
Check . typeOf . object ( "result" , result ) ;
526
522
//>>includeEnd('debug');
527
523
528
- // Convert from Cartesian UV space [0, 1] to Cartesian local space [-1, 1]
529
- const positionLocal = Cartesian3 . fromElements (
530
- positionUV . x * 2.0 - 1.0 ,
531
- positionUV . y * 2.0 - 1.0 ,
532
- positionUV . z * 2.0 - 1.0 ,
533
- result ,
534
- ) ;
535
-
536
524
let radius = Math . hypot ( positionLocal . x , positionLocal . y ) ;
537
525
let angle = Math . atan2 ( positionLocal . y , positionLocal . x ) ;
538
526
let height = positionLocal . z ;
539
527
540
528
const {
541
- cylinderUvToShapeUvRadius ,
542
- cylinderUvToShapeUvAngle ,
529
+ cylinderLocalToShapeUvRadius ,
530
+ cylinderLocalToShapeUvAngle ,
543
531
cylinderShapeUvAngleRangeOrigin,
544
- cylinderUvToShapeUvHeight ,
532
+ cylinderLocalToShapeUvHeight ,
545
533
} = this . _shaderUniforms ;
546
534
547
- radius = radius * cylinderUvToShapeUvRadius . x + cylinderUvToShapeUvRadius . y ;
535
+ radius = radius * cylinderLocalToShapeUvRadius . x + cylinderLocalToShapeUvRadius . y ;
548
536
549
537
// Convert angle to a "UV" in [0,1] with 0 defined at the center of the unoccupied space.
550
538
angle = ( angle + Math . PI ) / ( 2.0 * Math . PI ) ;
551
539
angle -= cylinderShapeUvAngleRangeOrigin ;
552
540
angle = angle - Math . floor ( angle ) ;
553
541
// Scale and shift so [0,1] covers the occupied space.
554
- angle = angle * cylinderUvToShapeUvAngle . x + cylinderUvToShapeUvAngle . y ;
542
+ angle = angle * cylinderLocalToShapeUvAngle . x + cylinderLocalToShapeUvAngle . y ;
555
543
556
- height = height * cylinderUvToShapeUvHeight . x + cylinderUvToShapeUvHeight . y ;
544
+ height = height * cylinderLocalToShapeUvHeight . x + cylinderLocalToShapeUvHeight . y ;
557
545
558
546
return Cartesian3 . fromElements ( radius , angle , height , result ) ;
559
547
} ;
0 commit comments