dataarts / webgl-globe

WebGL Globe is a platform for visualizing latitude longitude based information using WebGL.
https://experiments.withgoogle.com/chrome/globe
Other
3.61k stars 1.16k forks source link

Uncaught TypeError: Cannot read property 'x' of undefined #28

Closed codefrenzy closed 9 years ago

codefrenzy commented 9 years ago

Hi there,

I'm trying to render 8 different series, each with a different number of points in it (between 2 and 5 points, so really small amount of data).

This seems to cause the following error in the three.min.js library - Uncaught TypeError: Cannot read property 'x' of undefined. If I include less data (so 2 less points in the first series), this error is not thrown and the globe renders correctly. It's almost as though if the first series has more points in it than other series, it causes this error.

Does this mean that all series need to have the same number of points in them? Or that the first series should be the series with the most points? It seems that would be really limiting if that were the case. I hope it's not!

I'd really appreciate some help if at all possible :)

Cheers, Annie

mrdoob commented 9 years ago

Unfortunately this section is for bug reports and feature requests. For help request I would recommend using StackOverflow instead.

codefrenzy commented 9 years ago

Hi @mrdoob,

I understand - but I actually think this is a bug. It sounds very much along the same lines as https://github.com/dataarts/webgl-globe/issues/13 (see the last comment).

I think this is a bug with your three.js library because it works perfectly with other almost identical datasets. The error is thrown in your library, not my code. I'm happy to post a question on StackOverflow but I don't know how anyone who is using your libraries is going to know how to fix it if the problem is internal?

Cheers, Annie

codefrenzy commented 9 years ago

Hi again @mrdoob,

I've gotten a bit further in debugging this issue. I downloaded the un-minified version of three.js and can see the error is happening on line 19468:

vka[ offset_morphTarget ]     = v1.x;

If I add the following if statement around all the lines that refer to v1, v2 and v3:

if (typeof(v1) != 'undefined' && typeof(v2) != 'undefined' && typeof(v3) != 'undefined')

So in other words:

if (typeof(v1) != 'undefined' && typeof(v2) != 'undefined' && typeof(v3) != 'undefined')
{                   
    vka[ offset_morphTarget ]     = v1.x;
    vka[ offset_morphTarget + 1 ] = v1.y;
    vka[ offset_morphTarget + 2 ] = v1.z;

    vka[ offset_morphTarget + 3 ] = v2.x;
    vka[ offset_morphTarget + 4 ] = v2.y;
    vka[ offset_morphTarget + 5 ] = v2.z;

    vka[ offset_morphTarget + 6 ] = v3.x;
    vka[ offset_morphTarget + 7 ] = v3.y;
    vka[ offset_morphTarget + 8 ] = v3.z;                   
}

Then the globe renders without throwing any errors, although I think the points are no longer drawn in the correct place.

Would you consider this to be a bug?

Cheers, Annie

mrdoob commented 9 years ago

It sounds like it's a problem in the dataset itself. At the moment, this project doesn't double check that the data being passed is correct.

codefrenzy commented 9 years ago

Hi @mrdoob,

I can't see what would be wrong with the dataset. Like I said, I have 8 series, all of which have between 2~5 data points in them. This works fine if the first series only has 2 data points - which could be because all other series have at least 2 data points in them too. As soon as I add a third data point to the first series, it breaks. Hence my suspicion that the number of data points in each series either has to be equal or at the very least, have as many as the series before them.

Can you confirm if there is such a limitation? I'm happy to send you some data if it would help debug this.

Note - this happens with 2 series that have differing numbers of data points in them too.

mrdoob commented 9 years ago

Yes. All the data sets have to have equal amount of data points.

codefrenzy commented 9 years ago

Well that answers the question then. Can I put a feature request in to allow data sets with differing numbers of data points? :)

mrdoob commented 9 years ago

You can. But the project is a bit stale...

mattslocum commented 9 years ago

Can you explain the reason for the problem a little more? I'm having the same problem. Do I need to this.points = new THREE.Mesh(....) every time I call createPoints() on data that doesn't have the same points? Any help from a threeJS expert?