Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipping planes tweaks #6327

Merged
merged 11 commits into from
Mar 15, 2018
Merged

Conversation

likangning93
Copy link
Contributor

@cesium-concierge
Copy link

Signed CLA is on file.

@likangning93, thanks for the pull request! Maintainers, we have a signed CLA from @likangning93, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@likangning93
Copy link
Contributor Author

Discussion offline, might be better to move the "many clipping planes" demo to Terrain Clipping Planes and remove the drawing portion.

@lilleyse
Copy link
Contributor

It might make sense to move ClippingPlane to Scene as well.

@lilleyse
Copy link
Contributor

I'm not sure when the bug was introduced, but in 3D Tiles ClippingPlanes if you select the model and then uncheck Enable edge styling there is an error in the console: Uncaught TypeError: Cannot set property 'edgeWidth' of undefined (on line 200)

It looks like this is just a bug in the Sandcastle code.


var demos = ['Cesium Man', 'St. Helens'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency rename to exampleTypes.


// Create centerpoints for each clipping plane
var clippingPlanes = [];
for (var i = 0; i < pointCount; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: rename pointCount to pointsLength.
Change i++ to ++i


var pointCount = points.length;

// Create centerpoints for each clipping plane
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change centerpoints to center points.

};
var toolbar = document.getElementById('toolbar');
Cesium.knockout.track(viewModel);
Cesium.knockout.applyBindings(viewModel, toolbar);

// For tracking state when switching demos
var clippingPlanesEnabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't being used.

CHANGES.md Outdated
@@ -15,6 +15,8 @@ Change Log
* Added a `ClippingPlane` object to be used with `ClippingPlaneCollection`.
* Updated `WebMapServiceImageryProvider` so it can take an srs or crs string to pass to the resource query parameters based on the WMS version. [#6223](https://github.com/AnalyticalGraphicsInc/cesium/issues/6223)
* Added a multi-part CZML example to Sandcastle. [#6320](https://github.com/AnalyticalGraphicsInc/cesium/pull/6320)
* Added `AttributeCompression.octEncodeToCartesian4` and `AttributeCompression.octDecodeFromCartesian4` which will encode and decode unit-length normal vectors using 4 `uint8` components in a `Cartesian4`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be mentioned in CHANGES.md because the class is private.

@@ -25,6 +25,9 @@ define([
* opposite to the normal; if zero, the plane passes through the origin.
*/
function ClippingPlane(normal, distance) {
Check.typeOf.object('normal', normal);
Check.typeOf.number('distance', distance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap these 2 lines in

    //>>includeStart('debug', pragmas.debug);
    //>>includeEnd('debug');

z : makeGetterStter('z')
x : makeGetterSetter('x'),
y : makeGetterSetter('y'),
z : makeGetterSetter('z')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually just heed @pjcozzi's advice here and not do the separate makeGetterSetter that I had suggested, just in case. #6201 (comment)

@@ -90,8 +90,7 @@ define([
}
}

this._enabled = false;
this.enabled = defaultValue(options.enabled, true); // set using setter
this._enabled = defaultValue(options.enabled, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the default value of the setter is documented as false but it should be true.

@@ -1,18 +1,16 @@
define([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed some bugs in here thanks to Webstorm highlighting:

bug

The indexOf check is definitely a problem.
The second one is cosmetic, but would still be nice to fix. The file has a few occurrences of these issues.

@@ -374,7 +374,7 @@ defineSuite([
' 0.0, 2.0, 0.0, 0.0,' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add any other new builtins here, including unpackFloat.

@lilleyse
Copy link
Contributor

Another thing to fix:

I noticed that when a model is constructed with a color the color is not getting applied, probably because recreateProgram is not getting triggered. It's also possible this worked before createProgram was split into createProgram and recreateProgram. Do whatever seems right to make the fix.

@lilleyse
Copy link
Contributor

Example code:

var viewer = new Cesium.Viewer('cesiumContainer');

function createModel(url, height, heading, pitch, roll) {
    var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 0.0);
    var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll());

    var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({
        url : url,
        modelMatrix : modelMatrix,
        minimumPixelSize : 16,
        maximumPixelSize : 256,
        color : Cesium.Color.fromAlpha(Cesium.Color.BLUE, 0.85),
        colorBlendMode: Cesium.ColorBlendMode.HIGHLIGHT,
        silhouetteColor: Cesium.Color.fromAlpha(Cesium.Color.YELLOW, 1.0),
        silhouetteSize: 2.0
    }));

    model.readyPromise.then(function(model) {
        var camera = viewer.camera;

        // Zoom to model
        var controller = viewer.scene.screenSpaceCameraController;
        var r = 2.0 * Math.max(model.boundingSphere.radius, camera.frustum.near);
        controller.minimumZoomDistance = r * 0.5;

        var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3());
        var heading = Cesium.Math.toRadians(230.0);
        var pitch = Cesium.Math.toRadians(-20.0);
        camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, r * 2.0));
    }).otherwise(function(error){
        window.alert(error);
    });
}

createModel('../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb');

@likangning93
Copy link
Contributor Author

@lilleyse updated! Color on model construction should be fixed too.

CHANGES.md Outdated
@@ -15,6 +15,7 @@ Change Log
* Added a `ClippingPlane` object to be used with `ClippingPlaneCollection`.
* Updated `WebMapServiceImageryProvider` so it can take an srs or crs string to pass to the resource query parameters based on the WMS version. [#6223](https://github.com/AnalyticalGraphicsInc/cesium/issues/6223)
* Added a multi-part CZML example to Sandcastle. [#6320](https://github.com/AnalyticalGraphicsInc/cesium/pull/6320)
* Added 3D Tiles use-case to Terrain Clipping Planes Sandcastle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can go under the

  • ClippingPlaneCollection updates #6201

heading.

'../Core/Cartesian4',
'../Core/Math',
'../Core/Check',
'../Scene/ClippingPlane',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is out of order.

@@ -1,18 +1,18 @@
define([
'../Core/ClippingPlaneCollection',
'../Core/defined',
'../Core/destroyObject',
'../Core/TerrainQuantization',
'../Renderer/ShaderProgram',
'../Scene/SceneMode',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but for consistency this one should be changed to ./SceneMode

'Core/AttributeCompression',
'Core/BoundingSphere',
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Cartesian4',
'Core/ClippingPlane',
'Scene/ClippingPlane',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with Scene/ClippingPlaneCollection and Scene/ClippingPlane here.

@@ -1,5 +1,5 @@
defineSuite([
'Core/ClippingPlane',
'Scene/ClippingPlane',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

Copy link
Contributor Author

@likangning93 likangning93 Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I thought the define for the class being tested had to be first, but I hadn't looked at, say, the spec for Scene...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@likangning93 you are correct, the define for the class being tested does need to be first (because of Cesium specifics).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup sorry, I overlooked this case.

@lilleyse
Copy link
Contributor

Just those small things. Otherwise looks ready to go.

@likangning93
Copy link
Contributor Author

@lilleyse updated!

@lilleyse
Copy link
Contributor

Ok looks good. Thanks for all the changes!

@lilleyse lilleyse merged commit 21f3495 into CesiumGS:master Mar 15, 2018
@lilleyse lilleyse deleted the clippingPlanesTweaks branch March 15, 2018 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants