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

Models 2D/CV support #3764

Merged
merged 35 commits into from
May 26, 2016
Merged

Models 2D/CV support #3764

merged 35 commits into from
May 26, 2016

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Mar 23, 2016

Adds support for rendering models in 2D and Columbus view. Model.minimumPixelSize is not supported.

The only thing is changed is the computed model matrix. If the model is supposed to be deformed in 2D like other geometry, then the vertices need to be projected to 2D and this can be closed.

/**
* @private
*/
Transforms.basisTo2D = function(projection, matrix, result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is private, but is it worth writing a unit tests for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was moved from Camera that has a bunch of tests to make sure camera reference frames work in all scene modes. I'll add a couple of explicit tests though.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

Add a unit test for rendering in 2D and in CV.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

Update CHANGES.md.

@@ -28,7 +28,6 @@
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
scene3DOnly: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check all the Sandcastle examples with scene3DOnly: true. Perhaps the development on and CZML examples?

Copy link
Contributor

Choose a reason for hiding this comment

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

They are all OK.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

Model.minimumPixelSize is not supported.

OK with me, but update it's doc to state that.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

What's the plan for depth testing?

image

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

Part of #927.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 23, 2016

Also add info to the Model constructor function about the precision. This is fine for small models (it would be good if you can define-ish this), but only the origin takes into account the projection so each vertex in the model is slightly off, and more off as it goes away from the origin. For example create a box that is a million meters using a glTF model and Cesium geometries, and they will be in two different places since the later correctly projects all vertices.

@@ -3088,12 +3098,13 @@ define([
* @exception {RuntimeError} Failed to load external reference.
*/
Model.prototype.update = function(frameState) {
if (frameState.mode !== SceneMode.SCENE3D) {
if (frameState.mode === SceneMode.MORPHING) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine implement this will be non-trivial? It doesn't need to be part of this PR, but we could also fade it out/in.

@bagnell
Copy link
Contributor Author

bagnell commented Mar 24, 2016

Model.minimumPixelSize is not supported.

OK with me, but update it's doc to state that.

minimumPixelSize now works.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 24, 2016

minimumPixelSize now works.

Cool! Let me know when this is ready for another review.

@mramato let us know if you convert the demo CZML.

@mramato
Copy link
Contributor

mramato commented Mar 25, 2016

models2d

@pjcozzi pjcozzi mentioned this pull request Apr 12, 2016
@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 15, 2016

As discussed offline, let's detect when the model crosses the IDL and draw in both viewports.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 30, 2016

@bagnell let's aim to ship this for Cesium 1.22. Is there anything else needed besides #3764 (comment)?

@bagnell
Copy link
Contributor Author

bagnell commented Apr 30, 2016

@pjcozzi The z-fighting mentioned in #3764 (comment) is still an issue. We discussed a couple ways to fix it offline that I haven't tried yet.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 25, 2016

@bagnell is this ready for a final review and merge since #3953 was merged?

@bagnell
Copy link
Contributor Author

bagnell commented May 25, 2016

Yes, this should be good to go. The only change in this branch that wasn't reviewed or in the z-fighting or IDL PRs was some test fixes.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 26, 2016

Make the minimum pixel size 800 and infinite 2D goes away. Is this because the model's bounding sphere is so big?

image

var viewer = new Cesium.Viewer('cesiumContainer', {
    infoBox : false,
    selectionIndicator : false
});

function createModel(url, height) {
    viewer.entities.removeAll();

    var position = Cesium.Cartesian3.fromDegrees(-179.0744619, 44.0503706, height);
    var heading = Cesium.Math.toRadians(135);
    var pitch = 0;
    var roll = 0;
    var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);

    var entity = viewer.entities.add({
        name : url,
        position : position,
        orientation : orientation,
        model : {
            uri : url,
            minimumPixelSize : 800,
            //maximumScale : 20000
        }
    });
    viewer.trackedEntity = entity;
}

var options = [{
    text : 'Aircraft',
    onselect : function() {
        createModel('../../SampleData/models/CesiumAir/Cesium_Air.glb', 5000.0);
    }
}, {
    text : 'Ground vehicle',
    onselect : function() {
        createModel('../../SampleData/models/CesiumGround/Cesium_Ground.glb', 0);
    }
}, {
    text : 'Milk truck',
    onselect : function() {
        createModel('../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb', 0);
    }
}, {
    text : 'Skinned character',
    onselect : function() {
        createModel('../../SampleData/models/CesiumMan/Cesium_Man.glb', 0);
    }
}];

Sandcastle.addToolbarMenu(options);

@pjcozzi
Copy link
Contributor

pjcozzi commented May 26, 2016

The tests pass and all the code looks good. Just that comment.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 26, 2016

Turns out I was in CV.

@pjcozzi pjcozzi merged commit d8244f1 into master May 26, 2016
@pjcozzi pjcozzi deleted the models-2D branch May 26, 2016 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants