Hi everyone, I am trying to change the height of the 3D Model layer in this example but it doesn’t seem to work, I don’t know where I am wrong, someone help me
(Cesium Sandcastle)
Hello, welcome to the community!
The function fromCartesian takes a Cartesian3. That means that the input argument needs to be an instance of a Cartesian3. I see you have a point as an array. You can create a Cartesian3 from it by using the function Cartesian3.fromArray.
So instead of
const cartographic = Cesium.Cartographic.fromCartesian(
tileset.boundingSphere.center = [1215023.915542779,
-4736356.058240178, 4081642.5349159874]
);
We can do
const cartographic = Cesium.Cartographic.fromCartesian(
Cesium.Cartesian3.fromArray([1215023.915542779,
-4736356.058240178, 4081642.5349159874])
);
and it should work as you expect.
1 Like
sorry friend i copied the wrong link can you help me check in this example, i am trying cesium Cesium Sandcastle
it seems the way 3Dmodel works is different from 3DSettile
upppp
You can use Matrix4.multiplyByPoint to multiply x,y,z of cartesian3 as given below:
Cesium.knockout
.getObservable(viewModel, "height")
.subscribe(function (height) {
height = Number(height);
if (isNaN(height)) {
return;
}
console.log(entity,"entity");
const cartographic = Cesium.Cartographic.fromCartesian(
entity._position._value
);
const surface = Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
0.0
);
var newHpos = Cesium.Matrix4.multiplyByPoint(Cesium.Transforms.eastNorthUpToFixedFrame(surface),
new Cesium.Cartesian3(0, 0, height), new Cesium.Cartesian3());
entity.position.setValue(newHpos);
});
Here is the working sandcastle example.
- Regards
1 Like
fantastic, thank you very much, it’s so helpful
please help me with the case of rotating a 3Dtileset