Coder Social home page Coder Social logo

Comments (3)

MauricevanLeeuwen avatar MauricevanLeeuwen commented on July 28, 2024
var involuteGear = new involuteGear(params);
involuteGear.pitchRadius = 15;

This will change the pitchRadius property, but nothing more than that. Remember that the other properties, and also the resulting polygons, don't change when you change the pitchRadius:

var foo = 5;
var bar = foo * 5;
foo = 10;
console.log(bar); // prints 25

The current gear example code isn't well suited for what you want. You need to rebuild the complete model if you change a thing. So when you update something:

var changedInvoluteGear = new involuteGear(changedParams); 

I haven't looked much into OpenJSCad yet, but I don't believe there's another way to deal with changing parameters than with this.

If you want to change the way involuteGear works from time to time, you may do some prototypal inheritance

from openjscad.org.

Daubsy avatar Daubsy commented on July 28, 2024

Thanks for the feedback! I only need the the number of teeth, thickness, and center hole info for each gear. So would it be appropriate to separate these functions out as a prototype method and process them first?

from openjscad.org.

z3dev avatar z3dev commented on July 28, 2024

I can think of two options...

  1. Move the variables outside the function. This makes the variables "global" and can be accessed easily.
  2. Change the function to set a property on given parameter, i.e. return the calculated value as a property
    So, you'll have to change the code.

from openjscad.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.