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

Create multiple PolylineVolumeGeometry failed! #2372

Closed
zhhwdev opened this issue Jan 4, 2015 · 4 comments
Closed

Create multiple PolylineVolumeGeometry failed! #2372

zhhwdev opened this issue Jan 4, 2015 · 4 comments

Comments

@zhhwdev
Copy link

zhhwdev commented Jan 4, 2015

 var data = [
                {
                    _x1:120.37642905547698,
                    _y1:36.061823371641786,
                    _x2:120.37655731228237,
                    _y2:36.06155499305445
                },
                {
                    _x1:120.37655731228237,
                    _y1:36.06155499305445,
                    _x2:120.37679825061254,
                    _y2:36.06124201467066
                },
                {
                    _x1:120.37679825061254,
                    _y1:36.06124201467066,
                    _x2:120.37683543475069,
                    _y2:36.061192772612785
                },
                {
                    _x1:120.37683543475069,
                    _y1:36.061192772612785,
                    _x2:120.37697942800656,
                    _y2:36.06101208937304
                },
                {
                    _x1:120.37697942800656,
                    _y1:36.06101208937304,
                    _x2:120.37707935869126,
                    _y2:36.06090563235622
                },
                {
                    _x1:120.37707935869126,
                    _y1:36.06090563235622,
                    _x2:120.37709460455717,
                    _y2:36.06080494389364
                }
            ];
            var lines = [];
            for (var i=0; i<data.length; i++){
                var x1 = (data[i]._x1) * 1;
                var y1 = (data[i]._y1) * 1;
                var x2 = (data[i]._x2) * 1;
                var y2 = (data[i]._y2) * 1;

                var tube = new Cesium.GeometryInstance({
                    geometry: new Cesium.PolylineVolumeGeometry({
                        polylinePositions: Cesium.Cartesian3.fromDegreesArray([
                            x1, y1,
                            x2, y2
                        ]),
                        vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
                        shapePositions: computeCircle(3.0)
                    }),
                    attributes: {
                        color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED)
                    }
                });

                lines.push(tube);
            }

           that.scene.primitives.add(new Cesium.Primitive({
                    geometryInstances: lines,
                    appearance: new Cesium.PerInstanceColorAppearance({
                        translucent: false,
                        closed: false
                    })
                }));

if the array( data ) has more than three element, He had a mistake when i run the app:

An error occurred while rendering. Rendering has stopped.
TypeError: e is undefined i.subtract@http://localhost:8080/Cesium/Workers/createGeometry.js:58:6239 z.computePositions@http://localhost:8080/Cesium/Workers/createPolylineVolumeGeometry.js:230:3462 x.createGeometry@http://localhost:8080/Cesium/Workers/createPolylineVolumeGeometry.js:230:8212 r@http://localhost:8080/Cesium/Workers/createPolylineVolumeGeometry.js:230:8464 i@http://localhost:8080/Cesium/Workers/createGeometry.js:61:27886 n/<@http://localhost:8080/Cesium/Workers/createGeometry.js:61:27187

I do not know whether it is a bug!

thank you!

@mramato
Copy link
Contributor

mramato commented Jan 7, 2015

Please us the forum for help before filing a bug. In your code above, Cesium.Cartesian3.fromDegreesArray expects multiples of 3 (i.e. your array needs [x, y, z, x1, y1, z1], you only specify 4 values.

@mramato mramato closed this as completed Jan 7, 2015
@GatorScott
Copy link

Error in example in documentation for Cartesian3.fromDegreesArray shows 4 values in array: [-115.0, 37.0, -107.0, 33.0].

@mramato
Copy link
Contributor

mramato commented Jan 7, 2015

Actually, I was mistaken and my initial comment is wrong. fromDegreesArray does take pairs because height is ignored; it's fromDegreesArrayHeights that takes triplets. My apologies.

Actually running the code shows this is a duplicate of #2375, which @bagnell is currently working on.

@zhhwdev
Copy link
Author

zhhwdev commented Jan 9, 2015

I hava find the problem. Because some points is too close. I should increase the tolerance in the code. thanks.

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

No branches or pull requests

3 participants