How do I make a transformation matrix for my Cesium Primitive instance with only uniform scale

1. A concise explanation of the problem you're experiencing.

I need a modelMatrix to apply to my polyline geometry that only scales the geometry. I had to transform the vertices in the polylineGeometry model in order to get polylineGeometry to work so the vertices are already on the Earth's surface in the correct location and orientation. Now I need to rotate and scale them with a modelMatrix to make my Cesium.GeometryInstance for that polylineGeometry model.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

Polyline geometry is created at the correct location with this code:

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

var scene = viewer.scene;
var center = Cesium.Cartesian3.fromDegrees(45, 45, 100);
var originTransform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

var topLeft = new Cesium.Cartesian3(-100,0, 100);
var topRight = new Cesium.Cartesian3(100,0,100);
var btmRight = new Cesium.Cartesian3(100,0,-100);
var btmLeft = new Cesium.Cartesian3(-100,0,-100);

//calculate the positions for the square corners....
Cesium.Matrix4.multiplyByPoint(originTransform, topLeft, topLeft);
Cesium.Matrix4.multiplyByPoint(originTransform, topRight, topRight);
Cesium.Matrix4.multiplyByPoint(originTransform, btmRight, btmRight);
Cesium.Matrix4.multiplyByPoint(originTransform, btmLeft, btmLeft);

//draw the full square
var positionsXZ = [

var polyline = new Cesium.PolylineGeometry({
    positions: positionsXZ,
    width : 2.0,
    color : [Cesium.Color.RED]

var instance = new Cesium.GeometryInstance(
    {geometry : polyline});

scene.primitives.add(new Cesium.Primitive({

    geometryInstances : [instance],
    appearance : new Cesium.PolylineMaterialAppearance({
        material : Cesium.Material.fromType('Color')
    destination : Cesium.Cartesian3.fromDegrees(45, 45, 100)

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

Now I want to add a modelMatrix like this:

var instance = new Cesium.GeometryInstance(
    {geometry : polyline,
modelMatrix: myModelMatrixThatScalesAndRotatesThePolylineGeometry,

I'm having trouble because the modelMatrix requires rotation in the upper left of the matrix4, the scale in the rightmost column, and the translation in the bottom row of the matrix4 transformation matrix. I cant find what APIs I can use to make that format unless I use an Array, but I didn't want to revert to that. I wanted to use fromTranslationRotationScale, but I don't think that lays out the values in the matrix4 in the correct way. I think that puts the scale along the diagonal of the matrix like this for a uniform scale of 470.

incorrect modelMatrix :
(470, 0, 0, 0)
(0, 470, 0, 0)
(0, 0, 470, 0)
(0, 0, 0, 1)

correct modelMatrix (that I don't know how to make unless i use fromArray):
(1, 0, 0, 470)
(0, 1, 0, 470)
(0, 0, 1, 470)
(0, 0, 0, 1)
This has identity rotation, no translation and 470 scale.

4. The Cesium version you're using, your operating system and browser.
"cesium": "1.48.0"
chrome Version 73.0.3683.103 (Official Build) (64-bit)