Sandcastle Labels example, suggested update

247 views
Skip to first unread message

Left Gully

unread,
Jan 11, 2017, 2:39:56 PM1/11/17
to cesium-dev
In the interest of improving documentation, while I experimented in the Labels example, I realized there's an extra line of code in this function below.
It's redundantly setting a position for the billboard that's identical to the position of it's parent entity. If you don't delete the unnecessary line of code, perhaps add a comment explaining that it's only necessary if DIFFERENT than the parent entity, right?
Best regards-
-Jon

function offsetByDistance() {
    Sandcastle.declare(offsetByDistance);
    var image = new Image();
    image.onload = function() {
        viewer.entities.add({
            position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
            billboard : {
                //position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
                //position is inherited from parent entity, 
                //position is not necessary UNLESS specifying a DIFFERENT position than parent entity 
                //this could mislead someone getting started...

                //scaleByDistance : new Cesium.NearFarScalar(1.5e2, 5.0, 1.5e7, 0.5),
                image : image
            },
            label : {
                text : 'Label on top of scaling billboard',
                font : '20px sans-serif',
                showBackground : false,
                horizontalOrigin : Cesium.HorizontalOrigin.CENTER,
                pixelOffset : new Cesium.Cartesian2(0.0, -(image.height+(0.5*20))),
                eyeOffset: new Cesium.Cartesian3(0,0,-1),
                //pixelOffsetScaleByDistance : new Cesium.NearFarScalar(1.5e2, 3.0, 1.5e7, 0.5)
            }
        });
    };
    image.src = '../images/facility.gif';
}


Hannah Pinkos

unread,
Jan 11, 2017, 3:30:17 PM1/11/17
to cesium-dev
Thanks for pointing that out, Jon!  Deleting billboard.position seems like the right thing to do here.
Would you be interested in opening a pull request with the fix?  You can find instructions for doing this in our Contributing documentation here: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#opening-a-pull-request

Best,

Hannah

Scott Hunter

unread,
Jan 12, 2017, 10:32:09 AM1/12/17
to cesiu...@googlegroups.com
You're correct that the billboard position is unnecessary, likely a result of a copy/paste error in the example.  To clarify your explanation, however:  the billboard object literal here (which ends up being merged into a BillboardGraphics object, whose available properties are documented) simply does not have a position property at all.  In the example, it is entirely ignored. There is no notion that a billboard's position can be somehow different than the position of the containing entity.  

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages