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

Using Matter.Composite.bounds(composite) results in error when using as npm package #627

Closed
Qriva opened this issue Jun 6, 2018 · 1 comment
Labels

Comments

@Qriva
Copy link
Contributor

Qriva commented Jun 6, 2018

As above, in my project Matter is not global variable, only by import like this
import * as Matter from "matter-js";

that's why using Matter.Composite.bounds(composite) results in error because this function assumes that Matter will be global object:

Composite.bounds = function(composite) {
    var bodies = Matter.Composite.allBodies(composite), // here
        vertices = [];

    for (var i = 0; i < bodies.length; i += 1) {
        var body = bodies[i];
        vertices.push(body.bounds.min, body.bounds.max);
    }

    return Matter.Bounds.create(vertices); // and here 
};

so as long as I don't add manually Matter to be global, this method going to fail.

@liabru
Copy link
Owner

liabru commented Jun 11, 2018

Nice catch! That needs to be fixed, thanks for raising.

@liabru liabru added the bug label Jun 11, 2018
@liabru liabru closed this as completed in f7f77b4 Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants