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

Setting transparency to 3dtiles caused a crash #8394

Closed
verybigzhouhai opened this issue Nov 14, 2019 · 8 comments · Fixed by #9271
Closed

Setting transparency to 3dtiles caused a crash #8394

verybigzhouhai opened this issue Nov 14, 2019 · 8 comments · Fixed by #9271

Comments

@verybigzhouhai
Copy link
Contributor

As the title says, I set the color with transparency for my 3dtiles, and then the program crashes at some point during the program browsing. I tracked the error code and thought that the error might come from a gltf containing a mesh, but the mesh does not contain a primitive, so model._nodeCommands.length is 0. This caused the final crash.
So we need to determine if the first item of the array exists before accessing to solve this problem.
if (defined(nodeCommands[0]) && (!defined(nodeCommands[0].translucentCommand) || forceDerive)) { // code }
https://github.com/AnalyticalGraphicsInc/cesium/blob/63e97a531640b9cdd99b4eb20e1686a99d4f0eeb/Source/Scene/Model.js#L4028
image

@OmarShehata
Copy link
Contributor

Thanks for looking into this and opening the PR @verybigzhouhai ! Are you able to provide a Sandcastle example that reproduces this issue? The better fix may be to get the Model primitive to skip the update step if nodeCommands.length === 0, because there's at least one other update step that assumes an existence of nodeCommands[0]:

https://github.com/AnalyticalGraphicsInc/cesium/blob/63e97a531640b9cdd99b4eb20e1686a99d4f0eeb/Source/Scene/Model.js#L4268

@verybigzhouhai
Copy link
Contributor Author

@OmarShehata Ok, you are right. I have noticed the same problem with this code before. I will try to reproduce the problem with a simple model, not in the model I am using now.

@verybigzhouhai
Copy link
Contributor Author

@OmarShehata I reproduce this error, using the following code and the gltf file in the attached file. This gltf file contains the mesh, but does not contain any primitives. I want to add this judgment at the same time when judging whether to display the model update, how do you think?Or at an earlier time?
https://github.com/AnalyticalGraphicsInc/cesium/blob/63e97a531640b9cdd99b4eb20e1686a99d4f0eeb/Source/Scene/Model.js#L4737

But there seems to be no way to upload the gltf file as an attachment.I sent it to the gmail mailbox I saw in your profile, if you think this is not a good fit, please let me know the other way.

Below is the code. This error will be triggered when you click the button.

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

var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, -1000);
var heading = Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

var entity;

Sandcastle.addToolbarButton('test', function() {
entity = viewer.entities.add({
name : "",
position : position,
orientation : orientation,
model : {
uri : '1.gltf',
minimumPixelSize : 128,
maximumScale : 20000
}
});
viewer.trackedEntity = entity;
entity.model.color = Cesium.Color.WHITE.withAlpha(0.5);
});

@OmarShehata
Copy link
Contributor

@verybigzhouhai you can actually host your glTF model on Cesium ion now (https://cesium.com/ion) and then link it in your Sandcastle code.

I can see how this empty glTF reproduces the error, but I was hoping to see how this can be reproduced with a non empty 3D Tileset when setting it to transparent with the styling language (is that how you were setting the transparency?)

@verybigzhouhai
Copy link
Contributor Author

@OmarShehata Sorry, is there such a new development in this question?

@dzungpng
Copy link
Contributor

@verybigzhouhai This PR might be fixing the issue: #9271

@lilleyse
Copy link
Contributor

@verybigzhouhai sorry that your PR #8395 slipped through the cracks but #9271 was just merged and will hopefully fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants