-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Concave polygons not working even after I installed poly-decomp (node server) #559
Comments
Did you ever get this working? I am in the same boat, running a regular linux + apache server. Also, I see that the SVG demo no longer works. |
It looks like there is an issue with compiled JS renaming the |
Hi @bryantwells, I'm still having what seems to the same issue. Could you provide me with the versions of poly-decomp and matter that you are using? In my setup I am keeping the current version on github for both programs and using them in my html file as well as requiring the static file for poly decompress in node, which is how I interpreted your response. Perhaps I am still doing something wrong, but it seems to run but then returns as undefined when I create the body from vertices. |
I am having the same issue.
that did not solve the issue. Then tried to include it in the HTML
Here are package versions. "matter-js": "^0.14.1", |
Same problem here while trying to compile a project using webpack. Is there any workaround for this issue? I'm currently forced to abandon matter-js because of this. |
Hey @jobtalle, At the top of your webpack file include...
... and in the plugins array insert
Hope this helps. |
@rykerrumsey Thank you, this solved it for me! |
I have been fighting with this for 2 hours now and nothing seems to be helping. The Essentially, the way it was before commit 0cf97f5 would be working just fine if you would have simply included @liabru Any chance you would be willing to change it like that or is there some other tool/environment that you are aware of not supporting such an approach? |
Are you using the latest build? It's supposed to work everywhere unless there's a bug. The idea is it will look for a global first (e.g. when in a browser) otherwise it will fall back to require implementation provided by browserify and since it is a UMD build it will first check the the bundled dependencies (which do not include poly-decomp) then it should fall back to the environment Can you provide a stack trace and tell me more about your setup? What environment and build tools are you using? |
Yes, I have the latest version. I am using create-react-app (not ejected) so pretty straightforward configuration for bundling (with Webpack). I haven't used Browserify for years, it would probably work like that since you have the shim there. However, Webpack is a different beast and doesn't care about those shims. First of all, when Webpack is using your UMD bundle version, it won't bother parsing it (by default), so the I have tested this approach and it does make much more sense than some hacks with |
The fix provided by @rykerrumsey did not work for me, unfortunately. Is there currently a way to circumvent this problem without modifying matter.js? As it stands, polygon decomposition is not working for webpack environments. |
Thanks for the info guys, sorry that this is still an issue. While I look into it more, I think this temporary fix should work with the latest version. Make sure you put it somewhere early on, before you use window.decomp = require('poly-decomp'); |
No solutions for me thus far... |
all solutions above doesn't work so global window is remains untouched |
Using |
Finally I switched to box2d-js and it's working like a charm. Matter js is very buggy engine |
Same problem here. Switched to box2d-js. |
This worked for me (using Parcel as the bundler): import decomp from 'poly-decomp';
window.decomp = decomp; |
thx for your answer. |
Apologies for the problems here, it seems that every approach I had tried when originally using browserify for the build ended up having some edge cases depending on the environment. The newly released version I'd encourage those interested to try out the new version and let me know if this require problem is finally resolved. That said it is still recommended to eventually implement your own decomposition approaches suitable for your use case, using the built in function as a reference of how set up compound bodies. |
I'm now seeing this issue when running 0.15.0, when I didn't see it before. |
@cscuderi looks like there was a further issue in Can you try the latest release |
@liabru Gave it a shot, still seeing the issue though: |
@cscuderi could you tell me about your setup? Node.js or browser, build tools, config etc. |
Using
Then So can anybody else confirm if this is working fine in their project using Much appreciated any comments or thumbs up here. |
In addition to the above: anybody who is having trouble still with this please let me know:
|
"npm install poly-decomp --save " helped me in new create-react-app project with matter 0.16. |
An update on this: A few days ago I pushed version The demo has now been updated to be built with Webpack, so it should be easier to spot these kinds of issues in future. I have also improved the docs for Bodies.fromVertices as well as improving the missing dependency message. As I've not seen any further issues raised on this topic since the |
I've installed
poly-decomp
withnpm install poly-decomp
. I then putdecomp = require('poly-decomp')
abovematter = require('matter-js')
, when I run my code, it still sayspoly-decomp.js required
. I dug inmatter.js
code and changed line 6541 todecomp = require('poly-decomp')
. It doesn't give the same message anymore, but my shape is still just convex.I ran
console.log(decomp)
after line 6541, and it returnedwhich I think is what it should return. I dug even farther and made sure that line 6763 was being run, and it is. Although, when I
console.log(decomp.makeCCW(concave));
on line 6769, it returnsundefined
. What should I do to make it work? Right now it isn't giving me the error message, but it isn't making the shape concave.The text was updated successfully, but these errors were encountered: