I have learn about load gltf model, now I want know How to set z scale ?
this is my code:
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(121.466, 31.234, 200),
orientation: orientation,
model: {
//uri: 'SampleData/models/CesiumGround/Cesium_Ground.gltf',
uri: '地层/feature_53.gltf',
nodeTransformations: {
CLR1400000010703000000_54:{
scale: new Cesium.Cartesian3(1, 1, 10000)
}
}
}
});
viewer.zoomTo(entity);
there is an node by name in my gltf file. but set 10000 does not affect.
gary
June 29, 2017, 1:55pm
2
According to the ModelGraphics documentation , nodeTransformations should be a Cesium.TranslationRotationScale object instead of just a Cartesian3. See http://cesiumjs.org/Cesium/Build/Documentation/TranslationRotationScale.html .
在 2017年6月29日星期四 UTC+8下午9:55:30,Kangning Li写道:
According to the ModelGraphics documentation, nodeTransformations should be a Cesium.TranslationRotationScale object instead of just a Cartesian3. See http://cesiumjs.org/Cesium/Build/Documentation/TranslationRotationScale.html .
Thank you! I set it as an TranslationRotationScale object, but it does not affect.
在 2017年6月29日星期四 UTC+8下午9:55:30,Kangning Li写道:
在 2017年6月29日星期四 UTC+8下午9:55:30,Kangning Li写道:
According to the ModelGraphics documentation, nodeTransformations should be a Cesium.TranslationRotationScale object instead of just a Cartesian3. See http://cesiumjs.org/Cesium/Build/Documentation/TranslationRotationScale.html .
var r = new Cesium.TranslationRotationScale(Cesium.Cartesian3.ZERO, Cesium.Quaternion.IDENTITY,new Cesium.Cartesian3(1, 1, 10000));
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(121.466, 31.234, 200),
orientation: orientation,
model: {
//uri: 'SampleData/models/CesiumGround/Cesium_Ground.gltf',
uri: '地层/feature_53.gltf',
nodeTransformations: {
'CLR1400000010703000000_54': r
}
}
});
在 2017年6月29日星期四 UTC+8下午9:55:30,Kangning Li写道:
According to the ModelGraphics documentation, nodeTransformations should be a Cesium.TranslationRotationScale object instead of just a Cartesian3. See http://cesiumjs.org/Cesium/Build/Documentation/TranslationRotationScale.html .
Thank you! I set it as an TranslationRotationScale object, but it does not affect:
var r = new Cesium.TranslationRotationScale(new Cesium.Cartesian3(1, 1, 1000), Cesium.Quaternion.IDENTITY,new Cesium.Cartesian3(1, 1, 1000000));
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(121.466, 31.234, 200),
orientation: orientation,
model: {
//uri: 'SampleData/models/CesiumGround/Cesium_Ground.gltf',
uri: '地层/feature_53.gltf',
nodeTransformations: {
'"CLR1400000010704000000_1': r
}
}
});
gary
June 30, 2017, 1:24pm
7
Sorry, I just realized that the documentation says nodeTransformations needs to be a PropertyBag: http://cesiumjs.org/Cesium/Build/Documentation/ModelGraphics.html#nodeTransformations
Here’s the documentation for PropertyBag: http://cesiumjs.org/Cesium/Build/Documentation/PropertyBag.html
Can you give that a try?
Thank you, does not affect too, I Try it as that:
var trs = new Cesium.TranslationRotationScale(new Cesium.Cartesian3(1, 1, 1000), Cesium.Quaternion.IDENTITY,new Cesium.Cartesian3(1, 1, 1000000));
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(121.466, 31.234, 200),
orientation: orientation,
model: {
//uri: ‘SampleData/models/CesiumGround/Cesium_Ground.gltf’,
uri: ‘地层/feature_53.gltf’,
nodeTransformations: new Cesium.PropertyBag({
CLR1400000010704000000_1: trs
})
}
});
``
在 2017年6月30日星期五 UTC+8下午9:24:08,Kangning Li写道:
Is there any other way to set z scale for gltf model?
在 2017年6月30日星期五 UTC+8下午9:24:08,Kangning Li写道:
gary
June 30, 2017, 2:25pm
10
Hmmm, you can edit the gltf itself, but it seems odd that this doesn’t work. Here’s the specification: https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#transforms
Can you share the model? I can think of a couple possibilities too where something in the model doesn’t let it transform correctly.
model file been uploaded, you can try it again with that code:
var trs = new Cesium.TranslationRotationScale(new Cesium.Cartesian3(1, 1, 1), Cesium.Quaternion.IDENTITY,new Cesium.Cartesian3(1, 1, 10));
var heading = Cesium.Math.toRadians(0);
var pitch = Cesium.Math.toRadians(0.0);
var roll = Cesium.Math.toRadians(0.0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(Cesium.Cartesian3.fromDegrees(-71, 22, 0), new Cesium.HeadingPitchRoll(heading, pitch, roll));
var holes = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(-71, 22, 500),
orientation: orientation,
model: {
uri: 'test-z.gltf',
nodeTransformations: new Cesium.PropertyBag({
TEX1400000010101000000: trs
})
}
});
``
在 2017年6月30日星期五 UTC+8下午10:25:43,Kangning Li写道:
test-z.gltf (2.77 MB)
gary
July 4, 2017, 2:35am
12
My mistake… it looks like the code you posted as well as the 3D models example in Sandcastle is using the Entity API from this tutorial: https://cesiumjs.org/tutorials/Visualizing-Spatial-Data/ , which doesn’t seem to have full support for modifying model transformations yet.
Is it sufficient to scale entire models? That can be done by modifying this earlier method for placing models: https://cesiumjs.org/tutorials/3D-Models-Tutorial/
Here’s the code with the changes I made:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var scene = viewer.scene;
var scaleMatrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(1.0, 1.0, 5.0));
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 0.0));
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : ‘…/…/SampleData/models/CesiumGround/Cesium_Ground.gltf’,
modelMatrix : Cesium.Matrix4.multiply(modelMatrix, scaleMatrix, modelMatrix),
scale : 10.0
}));
viewer.camera.setView({
destination : Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 300.0),
orientation: {
heading : 0.0,
pitch : -Cesium.Math.PI_OVER_TWO,
roll : 0.0
}
});
``
``
gary
July 4, 2017, 3:05am
13
Ah. You might also be able to modify the model’s nodeTransformations after the entity has already been created.
Take a look at this Sandcastle example which modifies other properties like model’s color and outlining:
**Wow! Well, my problem is solved, thank you very much. I wish you a happy life!**
在 2017年7月4日星期二 UTC+8上午10:35:39,Kangning Li写道:
11115
September 4, 2020, 8:49am
15
This post is great help to me !! Thank you nodegis & gary.
1 Like