Skip to content

Reset a point light that has a body takes a lot of time #5934

@x-wk

Description

@x-wk

Version

  • Phaser Version: 3.55.2
  • Operating system: Win10
  • Browser:

Description

First create a static group, and add a lot of PointLight, and then calling 'body.reset', the time consumed is increasing as the number of calls increases. I don't know if this is the correct usage!

Example Test Code

create(){
      const group = this.physics.add.staticGroup();

      for (let i = 0; i < 20; i++) {
         for (let j = 0; j < 20; j++) {
            const p = new PointLight(this, i * 40 + 100, j * 40 + 100, 0xff0000, 20, Math.random())
               .addToDisplayList();
            group.add(p);
         }
      }

    const pl = new PointLight(this, 20, 20, 0xff0000, 20, 1)
         .addToDisplayList();
    group.add(pl);

    // Test
    setInterval(() => {
       console.time('body.reset');
       // this.pl.body.enable = false;
       // this.pl.body.enable = true;
       pl.body.reset(30, 30);
       console.timeEnd('body.reset');
    }, 1000);
}

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions