Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:31:55+00:00 2026-06-01T09:31:55+00:00

It may be a bit too specific, but maybe someone here has experience extending

  • 0

It may be a bit too specific, but maybe someone here has experience extending the particle class of toxiclib.js?

I keep getting:

 TypeError: this.setWeight is not a function

I am doing a very simple thing (I am using Processing.js):

  class Particle extends VerletParticle2D {

    Particle(float x, float y) {
      super(x,y);
    }

    void display() {
      stroke(0);
      ellipse(x,y,16,16);
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:31:56+00:00Added an answer on June 1, 2026 at 9:31 am

    Inheritance between Processing.js and other libraries is not all figured out yet. There is a workaround.

    First thing is to refer to VerletParticle2D by its full namespace:

    class Particle extends toxi.physics2d.VerletParticle2D
    

    Second part is to add this to toxiclibs.js’ constructor for VerletParticle2D (at the time of writing this, that is line #9941 of build/toxiclibs.js):

        if(!(this instanceof VerletParticle2D)){
          return new VerletParticle2D(x,y,w);
        }
    

    Third part is to add these 2 lines anywhere after you have defined your class. Unfortunately these 2 lines won’t play nice with the Processing IDE:

    Particle.prototype = new toxi.physics2d.VerletParticle2D();
    Particle.prototype.constructor = Particle;
    

    You can apply these 3 patterns to any other class as well to extend them.
    Also, Processing 2.0 Alpha 5 released a new feature that will pull a .js file next to an accompanying .jar. So if you place toxiclibs.js next to toxiclibscore.jar and rename it, it will get exported with your sketch. This will make it easier to have one version that you make some modifications to for extending classes.

    I have uploaded the web-exported sketch, with the modified toxiclibscore.js file here: http://haptic-data.com/toxiclibsjs/misc/ToxiclibsjsExtend.zip

    best of luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My usage-scenario may seem a bit unusual, but here it is: When using vim
This problem may be a bit too vast and nebulous for this space, but
This may be a bit of daft question, but I don't come from an
It may sound a bit weird, but in Bukkit (Minecraft Server) there's a permissions
The title may be a bit ambiguous, but I couldn't think of a better
The question may sound a bit stupid but I think it's interesting. Is it
The question may sound a bit naive or stupid, but i was wondering...will POST
I posted this once, but I was a bit too vague in my information,
Has anyone worked with the LiveUpdate function (may be a bit of a misnomer)
I am new to Java (but have a fair bit of .NET experience). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.