Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

454
Views
I want to disable collision detection while pressing the mouse. (Matter-js)

I'm writing code using p5js, a JavaScript library.
Right now, I'm making interactive art using Matter-js, a library of physics engines.

What I want to do is divide a picture into disjointed objects and mix them using a physics engine. Then, return to the original position so that the time will return with the passage of time or with a mouse click. I want to bring the object back and restore the picture.

I want to invalidate the collision detection of the object when returning this object to the initial position. If there is a collision detection, the objects will collide and you will not be able to return to the initial position.
Does anyone know a good way?

The URL of the application in the process of being created is posted below.   https://openprocessing.org/sketch/1387403

A part of the code of p5js is below. The whole code can be seen from the above URL.

function MonaBox(img, x, y, w, h) {
    let options = {
        friction: 0,
        restitution: 0.95,
    };
    this.body = Bodies.rectangle(x, y, w, h, options);
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.img = img;
    World.add(world, this.body);
    this.pos = this.body.position;
    this.angle = this.body.angle;
    

    this.show = function() {
        push();
        translate(this.pos.x, this.pos.y);
        rotate(this.angle);
        imageMode(CENTER);
        image(this.img, 0,0,this.w, this.h);
        pop();
    };

    this.update = function(isTouched){
        if(isTouched == false){
            this.pos = this.body.position;
            this.angle = this.body.angle;
        } else {
            if(this.pos.x != this.x){
                if(this.pos.x < this.x) this.pos.x +=0.1;
                if(this.pos.x > this.x) this.pos.x -=0.1;
            }
            if(this.pos.y != this.y){
                if(this.pos.y < this.y) this.pos.y +=0.1;
                if(this.pos.y > this.y) this.pos.y -=0.1;
            }
            if(this.angle != 0){
                if(this.pos.y < 0) this.pos.y +=0.1;
                if(this.pos.y > 0) this.pos.y -=0.1;
            }
        }
    };
}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!