Applying color to a model

39 views
Skip to first unread message

lepon...@gmail.com

unread,
Feb 10, 2017, 10:10:32 AM2/10/17
to cesium-dev
Hello all,

I am trying to colorize a model added to scene with no success.
This is the code i'm using:

var model = scene.primitives.add(
new Cesium.Model({
gltf : gltf_model,
modelMatrix : matrix,
color: Cesium.Color.BLUE
})
);

Thank you

Hannah Pinkos

unread,
Feb 10, 2017, 11:23:02 AM2/10/17
to cesium-dev, lepon...@gmail.com
Hello,

This example works for me: 

var viewer = new Cesium.Viewer('cesiumContainer');

var scene = viewer.scene;
var model;

var hpr = new Cesium.HeadingPitchRoll(0, 0, 0);
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 0);
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr);

model
= scene.primitives.add(Cesium.Model.fromGltf({
    url
: '../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb',
    modelMatrix
: modelMatrix,
    minimumPixelSize
: 128,
    color
: Cesium.Color.RED
}));


Make sure you're using the latest version of Cesium.  Model coloring was added fairly recently.  You can get the latest download here: http://cesiumjs.org/downloads.html

Best,

Hannah
Reply all
Reply to author
Forward
0 new messages