Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WallGeometry handling positions incorrectly #6050

Open
hpinkos opened this issue Dec 14, 2017 · 2 comments
Open

WallGeometry handling positions incorrectly #6050

hpinkos opened this issue Dec 14, 2017 · 2 comments

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Dec 14, 2017

Reported by @primozs

WallGeometry is not iterating through these positions correctly, resulting in trying to normalize the zero vector:

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

var dataFail = [{"x":4275839.559924875,"y":1108128.491490115,"z":4587218.256350457},{"x":4275839.560187584,"y":1108128.4915581993,"z":4587218.255867044},{"x":4275839.560187584,"y":1108128.4915581993,"z":4587218.255867044},{"x":4275839.560187584,"y":1108128.4915581993,"z":4587218.255867044},{"x":4275839.560187584,"y":1108128.4915581993,"z":4587218.255867044},{"x":4275839.560187584,"y":1108128.4915581993,"z":4587218.255867044},{"x":4275839.559983776,"y":1108128.4926396976,"z":4587218.25594444}];

var wall = {
  wall: {
    positions: dataFail, 
    material: Cesium.Color.fromCssColorString('red').withAlpha(0.2),
    outline: true,
    outlineColor: Cesium.Color.fromCssColorString('red').withAlpha(0.2)
  }
};
 
viewer.entities.add(wall);

viewer.scene.camera.flyTo({
    destination: new Cesium.Cartesian3(4275945.9824068565, 1107800.9025642173, 4587695.880722421),
});
@easternmotors
Copy link
Contributor

Can confirm this is still an issue in 1.67

@tkazik
Copy link

tkazik commented May 13, 2020

Yes, this bug is still valid...also in 1.69 (just took us 1h to figure that out :/).
The issue seems to be the following: If you add Cartesian3 with the same values, the difference will be the zero vector and normalization/division with a zero vector will make the program crash.
We did the following workaround: Only add points to the wall (tmpPos), that have a difference bigger than an epsilon3:

            var tmpC3 = new Cartesian3(W_t_W_C.x, W_t_W_C.y, W_t_W_C.z);
            var myDiff = new Cartesian3(0,0,0);
            if (tmpPos.length > 0 ) {
                Cartesian3.subtract(tmpC3, tmpPos[tmpPos.length-1], myDiff);
                if (!Cartesian3.equalsEpsilon(myDiff, Cartesian3.ZERO, CesiumMath.EPSILON3)) {
                    tmpPos.push(tmpC3)
                } else {
                    console.log("diff is ZEROOOO");
                }
            } else {
                tmpPos.push(tmpC3)
            }

But yes, it would be nicer, if that bug would be fixed within Cesium :) Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants