You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error happens when creating more than 1 model using new Model(). It looks like the second models animation is using the rotation from the first model.
In the example below, the truck wheels use the rotation of the plane propellers.
I've included a sandcastle example below. To reproduce, switch between truck and plane twice. The first time creates the models using fromGltf. The second time creates the models using new Model and the truck should show the bad animation.
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var planegltf;
var groundgltf;
function createModel(url, height, name) {
height = Cesium.defaultValue(height, 0.0);
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height));
scene.primitives.removeAll(); // Remove previous model
var options = {
modelMatrix : modelMatrix,
minimumPixelSize : 128
};
var model;
if (name === 'plane' && Cesium.defined(planegltf)) {
options.gltf = planegltf;
model = scene.primitives.add(new Cesium.Model(options));
} else if (name === 'ground' && Cesium.defined(groundgltf)) {
options.gltf = groundgltf;
model = scene.primitives.add(new Cesium.Model(options));
} else {
options.url = url;
model = scene.primitives.add(Cesium.Model.fromGltf(options));
}
model.readyToRender.addEventListener(function(model) {
if (name === 'plane' && !Cesium.defined(planegltf)) {
planegltf = model.gltf;
}
if (name === 'ground' && !Cesium.defined(groundgltf)) {
groundgltf = model.gltf;
}
// 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);
});
}
///////////////////////////////////////////////////////////////////////////
var options = [{
text : 'Aircraft',
onselect : function() {
createModel('../../SampleData/models/CesiumAir/Cesium_Air.gltf', 5000.0, 'plane');
}
}, {
text : 'Ground vehicle',
onselect : function() {
createModel('../../SampleData/models/CesiumGround/Cesium_Ground.gltf', 0.0, 'ground');
}
}];
Sandcastle.addToolbarMenu(options);
The text was updated successfully, but these errors were encountered:
The error happens when creating more than 1 model using
new Model()
. It looks like the second models animation is using the rotation from the first model.In the example below, the truck wheels use the rotation of the plane propellers.
I've included a sandcastle example below. To reproduce, switch between truck and plane twice. The first time creates the models using
fromGltf
. The second time creates the models usingnew Model
and the truck should show the bad animation.The text was updated successfully, but these errors were encountered: