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

SurfaceMeshBuilder + Sphere Circular Dependency issue in build #18

Closed
hapticdata opened this issue Jan 12, 2012 · 8 comments
Closed

SurfaceMeshBuilder + Sphere Circular Dependency issue in build #18

hapticdata opened this issue Jan 12, 2012 · 8 comments

Comments

@hapticdata
Copy link
Owner

Currently there is a circular dependency issue between toxi.geom.mesh.SurfaceMeshBuilder and toxi.geom.Sphere in the toxiclibs.js or toxiclibs.min.js builds. This can cause toxi.geom.Sphere#toMesh to fail.

@hapticdata
Copy link
Owner Author

Sphere#toMesh issue now only appears in rare use as an individual AMD module before using the require.js build process, at times of latency.

@almostscientific
Copy link

I'm having a problem with SurfaceMeshBuilder:

var mesh = new toxi.geom.Sphere(80).toMesh(null, 20);

line 5671 in toxiclibs.js

var builder = new SurfaceMeshBuilder(new SphereFunction(this));
Uncaught TypeError: undefined is not a function

@hapticdata
Copy link
Owner Author

It appears to me that you are using v0.1.0, can you please try the v0.1.1 (the current master) and confirm you are still experiencing this issue? this has been a tricky one.

@almostscientific
Copy link

Okay, I just downloaded the current master f54bd6a and I'm still getting the error.

@hapticdata
Copy link
Owner Author

Ok, I am able to recreate the error on my side. I've put a possible temporary workaround in this gist: https://gist.github.com/2377350

the error only persists if the mesh is constructed within the first second after window.onload is called. if there is any sort of delay first (or say the mesh is intended to be constructed by a user interaction) then it works successfully. The error occurs because at that time the module 'toxi/geom/mesh/TriangleMesh' has not yet been resolved.

this is high priority for the next release.

@hapticdata
Copy link
Owner Author

Having a hard time putting this down :) I am able to get the whole thing working (without any delay) by making TriangleMesh#getBoundingSphere an asynchronous call, which isn't a perfect solution, but might be the best possible for this type of circular dependency.

So, https://github.com/hapticdata/toxiclibsjs/tree/issue_18 the build file in that should work fine, however if in slim-chance you are going to need TriangleMesh#getBoundingSphere you will need to use it like so:

mesh.getBoundingSphere(function( sphere ) {
    console.log( sphere );
});

@hapticdata
Copy link
Owner Author

This issue has been resolved in the develop branch, without the use of asynchronous functions. It will be merged to master soon with the next release.

@hapticdata
Copy link
Owner Author

this was merged to master for v0.1.3

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

2 participants