Skip to content

Commit

Permalink
fix 3d: add 90 deg yaw rotation for plane model
Browse files Browse the repository at this point in the history
Regression from 13705a1.
Apparently when I tested it, the previous model was still used due to
caching.
  • Loading branch information
bkueng committed Jan 7, 2025
1 parent e161e6f commit b779d55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/plot_app/templates/3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@

var model_scale_factor = {{ model_scale_factor }}; // model-specific scale factor
var model_uri = "{{ model_uri }}";
var model_heading_rotation_deg = "{{ model_heading_rotation_deg }}";

//Make sure viewer is at the desired time.
viewer.clock.startTime = start.clone();
Expand Down Expand Up @@ -242,7 +243,7 @@
return property;
}

function computeOrientationProperty() {
function computeOrientationProperty(heading_rotation_deg) {
//var orientationProperty = new Cesium.SampledProperty(Cesium.Quaternion);
var orientationProperty = new Cesium.TimeIntervalCollectionProperty();

Expand All @@ -256,6 +257,9 @@
var rotation_matrix = new Cesium.Matrix3();
Cesium.Matrix4.getRotation(transform_matrix, rotation_matrix);

// Rotate the model to point east
var m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(heading_rotation_deg));
rotation_matrix = Cesium.Matrix3.multiply(rotation_matrix, m, new Cesium.Matrix3());
// rotation quaterion from ENU to ECEF
var q_enu_to_ecef = Cesium.Quaternion.fromRotationMatrix(rotation_matrix);

Expand Down Expand Up @@ -299,7 +303,7 @@

//Compute the entity position & orientation properties
var positionProperty = computePositionProperty(0);
var orientationProperty = computeOrientationProperty();
var orientationProperty = computeOrientationProperty(model_heading_rotation_deg);

// flight modes
var flightModesProperty = new Cesium.TimeIntervalCollectionProperty();
Expand Down
4 changes: 4 additions & 0 deletions app/tornado_handlers/three_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ def get(self, *args, **kwargs):
# the model_scale_factor should scale the different models to make them
# equal in size (in proportion)
mav_type = ulog.initial_parameters.get('MAV_TYPE', None)
model_heading_rotation_deg = 0
if mav_type == 1: # fixed wing
model_scale_factor = 0.06
model_uri = 'plot_app/static/cesium/SampleData/models/CesiumAir/Cesium_Air.glb'
model_heading_rotation_deg = 90
elif mav_type == 7: # Airship, controlled
model_scale_factor = 0.1
model_uri = 'plot_app/static/cesium/SampleData/models/CesiumBalloon/CesiumBalloon.glb'
Expand All @@ -172,6 +174,7 @@ def get(self, *args, **kwargs):
# TODO: use the delta-quad model
model_scale_factor = 0.06
model_uri = 'plot_app/static/cesium/SampleData/models/CesiumAir/Cesium_Air.glb'
model_heading_rotation_deg = 90
else: # TODO: handle more types
model_scale_factor = 1
model_uri = 'plot_app/static/cesium/models/iris/iris.glb'
Expand All @@ -190,6 +193,7 @@ def get(self, *args, **kwargs):
attitude_data=attitude_data,
model_scale_factor=model_scale_factor,
model_uri=model_uri,
model_heading_rotation_deg=model_heading_rotation_deg,
log_id=log_id,
cesium_api_key=get_cesium_api_key()))

0 comments on commit b779d55

Please sign in to comment.