function createModel(url, height) { height = Cesium.defaultValue(height, 0.0); var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height)); var rotateMatrix = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0)); var rotation4 = Cesium.Matrix4.fromRotationTranslation(rotateMatrix,Cesium.Cartesian3.ZERO); var rotatedModel = Cesium.Matrix4.multiply( modelMatrix,rotation4, modelMatrix); scene.primitives.removeAll(); // Remove previous model var model = scene.primitives.add(Cesium.Model.fromGltf({ url : url, modelMatrix : rotatedModel, minimumPixelSize : 128 }));
model.readyToRender.addEventListener(function(model) { // Play and loop all animations at half-spead model.activeAnimations.addAll({ speedup : 0.5, loop : Cesium.ModelAnimationLoop.REPEAT });
// Zoom to model var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3()); var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center); var camera = scene.camera; camera.transform = transform; var controller = scene.screenSpaceCameraController; var r = 2.0 * Math.max(model.boundingSphere.radius, camera.frustum.near); controller.minimumZoomDistance = r * 0.5; camera.lookAt(new Cesium.Cartesian3(r, r, r), Cesium.Cartesian3.ZERO, Cesium.Cartesian3.UNIT_Z); });}
--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/q01DY3kPxtg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
It would be extremely helpful if someone could post an example of how to manipulate the heading, roll and pitch of a model... with examples of how to manipulate any one of these parameters individually as well as manipulating two or more of these parameters at the same time!
Below is a combination of the help we've found on the forums. We converted a bunch of models prior to the recent changes in the gltf converter. So some of the code here deals with the current orientation of our models. We are able to adjust one of the parameters successfully (for instance the heading), but we have not been able to adjust multiple parameters.
var tempMatrix = new Cesium.Matrix4();
var rotMatrixRoll = new Cesium.Matrix3();
Cesium.Matrix3.fromRotationY(degreesToRadians(0), rotMatrixRoll);
var rotMatrixPitch = new Cesium.Matrix3();
Cesium.Matrix3.fromRotationX(degreesToRadians(pos.PITCH), rotMatrixPitch);
var rotMatrixHdg = new Cesium.Matrix3();
Cesium.Matrix3.fromRotationZ(degreesToRadians(pos.HDG + 90), rotMatrixHdg);
// var currOrient = new Cesium.Matrix3();
// Cesium.Matrix3.multiply(rotMatrixPitch, rotMatrixHdg, currOrient);
//
// Cesium.Matrix4.fromRotationTranslation(currOrient,
// new Cesium.Cartesian3(0.0, 0.0, 0.0), tempMatrix);
Cesium.Matrix4.fromRotationTranslation(rotMatrixHdg, new Cesium.Cartesian3(0.0, 0.0, 0.0), tempMatrix);
//Orient models that are rightside up, currently the models are upside down
// Cesium.Matrix4.multiply(Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(pos.LON,pos.LAT, pos.ALT * dblFEET_TO_METERS)),
Cesium.Matrix4.multiply(Cesium.Transforms.northEastDownToFixedFrame(Cesium.Cartesian3.fromDegrees(pos.LON,pos.LAT, pos.ALT * dblFEET_TO_METERS)),
tempMatrix,
this.Model.modelMatrix);