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
Expose Model through the entity API #7378
Comments
Hello @bivald! Thanks for opening this issue, but this isn't something we're going to be able to do with the current version of the Entity API. The Entity API is meant to provide a level of abstraction away from the underlying primitives. Depending on whether you're using certain dynamic properties, the primitive might actually be destroyed and swapped out with a new one, so exposing the primitive to the end-user may result in unexpected behavior. If you need to make changes to lower level model properties like you're describing, I would recommend creating and updating the model primitive yourself. We're happy to help if you have questions about this! |
Congratulations on closing the issue! I found these Cesium forum links in the comments above: https://groups.google.com/forum/#!topic/cesium-dev/4wVIah9ZAuk If this issue affects any of these threads, please post a comment like the following:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
Thank you @hpinkos, good points. I would be more then happy to use my own primitives, but have found it hard to enable the Entity API features, such as trackedEntity and position/orientation. The mailing list is best way to get help and pointers about this, right? |
@bivald Here is some sample code. It shows how to convert position/orientation to a modelMatrix, and how to use But yes, the mailing list is the best place to ask for help if you encounter any other issues. Our team also monitors the mailing list so make sure every question gets attention. Thanks! var viewer = new Cesium.Viewer('cesiumContainer', {
shouldAnimate : true,
shadows : true
});
var scene = viewer.scene;
var url = '../../SampleData/models/CesiumAir/Cesium_Air.glb';
var height = 10000.0;
var heading = Cesium.Math.toRadians(30.0);
var pitch = Cesium.Math.toRadians(10.0);
var roll = Cesium.Math.toRadians(20.0);
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr);
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : url,
modelMatrix : modelMatrix
}));
model.readyPromise.then(function(model) {
model.activeAnimations.addAll({
speedup : 0.5,
loop : Cesium.ModelAnimationLoop.REPEAT
});
var camera = viewer.camera;
var controller = 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){
console.log(error);
}); |
I understand why we can't expose the primitive, but it still feels like the Entity API is awfully limited with regards to controlling animation. Like it currently allows me to set This PR #7361 adds the ability to control the animation speed, but still doesn't allow you to control other things. I wonder if it would be worth creating a |
@OmarShehata we can certainly consider piping more things through. It's just that no one's asked for it yet. |
Yes, instead of just exposing underlying primitives, what we should be doing is expanding the Entity API to handle our users use cases. |
In a way this is related to #4727, but I wanted to ask anyway. First of all, super big thank you for Cesium - it's truly an awesome tool!
It would be great if the underlying model was exposed through the entity API. I describe the reasons in https://groups.google.com/forum/#!topic/cesium-dev/4wVIah9ZAuk, but in short they are:
Currently I use nodeTransformation which works for some parts, but it would be exciting to be able to manipulate the actual model (similar to what you can do on an SVG).
I do realize this might be awkward, since you would need to expose the promises for model loaded etc. But it would strike a great balance between features (in the Model) and ease of use (of the Entity API)
The text was updated successfully, but these errors were encountered: