cesium primitive bug

function create() {

createPrimitive(‘1’,

-15.5, -15.5, 15.5, 15.5, ‘Images/Koala.jpg’);

            //-15, -15, 15, 15, 'Images/Koala.jpg');**If the argument is a decimal, the two pictures that are created will cross, as shown in the attachment.and ****scene.primitives.lowerToBottom 、****raiseToTop。doesn't work。****If the argument is an integer, the picture appears normal.**

createPrimitive(‘2’,

-20, -20, 30, 30, ‘Images/Lighthouse.jpg’);

}

//创建Primitive

var createPrimitive = function (id, west, south, east, north, imagepath) {

let instance = new Cesium.GeometryInstance({

id: id,

geometry: new Cesium.RectangleGeometry({

rectangle: Cesium.Rectangle.fromDegrees(west, south, east, north)

}),

});

var myPrimitive = new Cesium.Primitive({

geometryInstances: instance,

appearance: new Cesium.MaterialAppearance({

material: new Cesium.Material({

fabric: {

type: ‘Image’,

uniforms: {

image: imagepath

}

}

})

})

});

scene.primitives.add(myPrimitive);

}

``

two bug

**1:****If the argument( ****new Cesium.Rectangle(west, south, east, north) ) ****is a decimal, the two pictures that are created will cross, and ****scene.primitives.lowerToBottom 、****raiseToTop…doesn’t work。**If the argument is an integer, the picture appears normal.

**2:****If you manipulate the two-rectangle matrix, the rectangle rotates to the other latitude and longitude of the ball, can cause two of pictures to cross display,****and **scene.primitives.lowerToBottom 、raiseToTop…doesn’t work。For example:

var calRotateMatrix = function(lon, lat) {

            var modelMatrix;

            if (scene.mode == 3) {

                let rotatez = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(lon));

                let rotatex = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(0 - lat));

                modelMatrix = Cesium.Matrix4.IDENTITY;

                modelMatrix = Cesium.Matrix4.multiplyByMatrix3(modelMatrix, rotatez, new Cesium.Cartesian4());

                modelMatrix = Cesium.Matrix4.multiplyByMatrix3(modelMatrix, rotatex, new Cesium.Cartesian4());

            } 

            return modelMatrix;

        }

function create() {

       var modelMatrix1 =calRotateMatrix (50,80);
       var modelMatrix2 =calRotateMatrix (50,70);

        createPrimitive('1',-15, -15, 15, 15, 'Images/Koala.jpg',modelMatrix1);

createPrimitive(‘2’,-20, -20, 30, 30, ‘Images/Lighthouse.jpg’,modelMatrix2);

    }

//创建Primitive

var createPrimitive = function (id, west, south, east, north, imagepath,modelMatrix) {

let instance = new Cesium.GeometryInstance({

id: id,

geometry: new Cesium.RectangleGeometry({

rectangle: Cesium.Rectangle.fromDegrees(west, south, east, north)

}),

});

var myPrimitive = new Cesium.Primitive({

geometryInstances: instance,

appearance: new Cesium.MaterialAppearance({

material: new Cesium.Material({

fabric: {

type: ‘Image’,

uniforms: {

image: imagepath

}

}

})

            }),
           **modelMatrix: modelMatrix**

});

scene.primitives.add(myPrimitive);

}

``

Hi there,

For bug #1, I don’t see why using a decimal should cause that effect. Can you create a Sandcastle example that shows the problem? If there’s a bug, I can open an issue in GitHub.

For bug #2, only GroundPrimitives will respect ordering.

Thanks,

Gabby

Hi,

If I have the arrays of geometry vertices & normals already, and I want to map some images onto the the 3D GeometryInstance using uv mapping,

should I set the Geometry.attributes.st and Primitive.appearance.material.fabric (type=‘Image’)? or somewhere else I can set up the image path and uv arrays?

My current code of adding primitive from geometry data:

               let geometry = new Cesium.Geometry({
                    attributes: {
                        position: new Cesium.GeometryAttribute({
                            componentDatatype: Cesium.ComponentDatatype.DOUBLE,
                            componentsPerAttribute: 3,
                            values: positions // vertices array
                        }),
                        normal: new Cesium.GeometryAttribute({
                            componentDatatype: Cesium.ComponentDatatype.FLOAT,
                            componentsPerAttribute: 3,
                            values: normals // normals array
                        })
                    },
                    primitiveType: Cesium.PrimitiveType.TRIANGLES,
                    boundingSphere: Cesium.BoundingSphere.fromVertices(positions)
                });

                var instance = new Cesium.GeometryInstance({
                    geometry: geometry,
                    attributes: {
                        color: Cesium.ColorGeometryInstanceAttribute.fromColor(color)
                    },
                    show: new Cesium.ShowGeometryInstanceAttribute(true)
                });

                instances.push(instance);

                var primitive = viewer.scene.primitives.add(new Cesium.Primitive({
                    geometryInstances: instances,
                    appearance: new Cesium.PerInstanceColorAppearance({
                        closed: true,
                        translucent: false
                    })
                }));

``

Gabby Getz於 2018年7月25日星期三 UTC+8下午10時52分32秒寫道:

I see you already figured out some of this before I posted in your other thread:

https://groups.google.com/d/msg/cesium-dev/aBnjIVt-dmU/jXGnKTGKCAAJ

But feel free to follow up there if my suggestions in that thread don’t help.

Hi,I also try to add a customt geometry to cesium,Cloud you share some test data of positions and normals ?

在 2018年11月8日星期四 UTC+8上午9:28:12,CrashedBboy写道: