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

Hide Outlines for 3D Models #9629

Merged
merged 18 commits into from
Jun 27, 2021
Merged

Hide Outlines for 3D Models #9629

merged 18 commits into from
Jun 27, 2021

Conversation

srothst1
Copy link
Contributor

Fixes #8959

Added a new property ignoreOutline to Model.js and Cesium3DTileset.js. Based on this property, the line ModelOutlineLoader.outlinePrimitives(this); in Model.js will be either included or omitted. This exposes the ability to turn off outlines on 3D models.

The current issue that I am facing is that this.ignoreOutline is not being updated correctly in Model.js. I created a sandcastle demo that showcases this issue. Please let me know what your suggestions are for resolving this.

Lastly, there was a discussion in #8959 about where this new property should be implemented. It is unclear if this feature should only be implemented for Cesium OSM Buildings. Feedback on this matter would also be apricated.

@ebogo1
@lilleyse

@cesium-concierge
Copy link

Thanks for the pull request @srothst1!

  • ✔️ Signed CLA found.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

Copy link
Contributor

@ebogo1 ebogo1 left a comment

Choose a reason for hiding this comment

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

These changes look mostly good to me. Do we want to allow users to swap this option after initialization?

Source/Scene/Model.js Outdated Show resolved Hide resolved
@srothst1
Copy link
Contributor Author

@ebogo1 It does not seem necessary to allow users to change this option after initialization. I have not seen anything in the community forum that suggests that this functionality is critical.

Source/Scene/Batched3DModel3DTileContent.js Outdated Show resolved Hide resolved
Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
Source/Scene/Model.js Outdated Show resolved Hide resolved
Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
@lilleyse
Copy link
Contributor

@ebogo1 It does not seem necessary to allow users to change this option after initialization. I have not seen anything in the community forum that suggests that this functionality is critical.

Ideally it would be toggleable. However I don't think the current Model code is flexible enough for that right now, and it's not a dealbreaker for this PR.

CC @ptrgags @sanjeetsuhag when you go to integrate CESIUM_primitive_outline in the new model code try to make it flexible enough for toggling on/off after construction.

@srothst1
Copy link
Contributor Author

srothst1 commented Jun 24, 2021

@lilleyse Thank you for your suggestions! I believe I have incorporated all of your feedback:

  1. changed ignoreOutline to showOutline and setting the default value to true
  2. added descriptions mentioning CESIUM_primitive_outline and updating CHANGES.md according to your specification
  3. changed the new method to @readonly where applicable
  4. added something similar to ignoreOutline: tileset.ignoreOutline in Instanced3DModel3DTileContent and ModelInstanceCollection
  5. documented the showOutline option in createOsmBuildings

Let me know if you have any questions, comments, or concerns.

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

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

Getting close...

Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
Source/Scene/ModelInstanceCollection.js Outdated Show resolved Hide resolved
Source/Scene/createOsmBuildings.js Outdated Show resolved Hide resolved
Source/Scene/createOsmBuildings.js Outdated Show resolved Hide resolved
@srothst1
Copy link
Contributor Author

@lilleyse I just

  1. updated the documentation for Cesium3DTileset.js and Model.js
  2. changed where showOutline is added in ModelInstanceCollection.js
  3. removed the \ from createOsmBuildings.js
  4. added a more tailored description of showOutline to createOsmBuildings.js

Hopefully I didn't miss anything - let me know!

@lilleyse
Copy link
Contributor

The code looks good! I just left one comment about testing.

…wOutline: false and not call ModelOutlineLoader.outlinePrimitives
@srothst1
Copy link
Contributor Author

@lilleyse I just added a spec to ModelSpec.js. This spec should test loading a glTF 2.0 model with showOutline : false and ensuring that ModelOutlineLoader.outlinePrimitives is not called by using a spy spyOn(ModelOutlineLoader, "outlinePrimitives");.

Comment on lines 1210 to 1228
it("loads a glTF 2.0 model with showOutline set as false", function () {
return loadModel(boxGltf2Url).then(function (m) {
verifyRender(m);
m.show = true;
m.luminanceAtZenith = undefined;
m.showOutline = false;
spyOn(ModelOutlineLoader, "outlinePrimitives");

expect({
scene: scene,
time: JulianDate.fromDate(new Date("January 1, 2014 12:00:00 UTC")),
}).toRenderAndCall(function (rgba) {
expect(rgba).toEqualEpsilon([179, 9, 9, 255], 5); // Red
});
expect(ModelOutlineLoader.outlinePrimitives).not.toHaveBeenCalled();

primitives.remove(m);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

The test can be simplified by using the options parameter for loadModel

    it("loads a glTF 2.0 model with showOutline set as false", function () {
      spyOn(ModelOutlineLoader, "outlinePrimitives");
      return loadModel(boxGltf2Url, {
        showOutline: false
      }).then(function (m) {
        expect(ModelOutlineLoader.outlinePrimitives).not.toHaveBeenCalled();
        primitives.remove(m);
      });
    });

@srothst1
Copy link
Contributor Author

@lilleyse just committed your suggestions.

@lilleyse
Copy link
Contributor

Thanks @srothst1!

@lilleyse lilleyse merged commit c78cec0 into master Jun 27, 2021
@lilleyse lilleyse deleted the 3D-model-outline branch June 27, 2021 23:07
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.

Expose ability to turn off outlines for 3D models?
4 participants