Three.js: CatmullRom3 Sets tension=0.5 if initialized with tension=0

Created on 29 Jun 2020  路  1Comment  路  Source: mrdoob/three.js

Description of the problem

If I generate a CatmullRomCurve3 with tension=0, the curve will actually initialize with a tension=0.5

        const curve = new THREE.CatmullRomCurve3(
          points,  // Tension
          true,  // Closed
          "catmullrom",  // Type
          0  // Tension
        )

Bug: Tension = 0.0 looks like Tension = 0.5

image

Expected: Tension = 0.0

image

_I'm achieving this look for the screenshot by setting tension=0.001_

I believe this is caused by this code in the initializer:

this.tension = tension || 0.5;

Which should be something like:

const defaultTension = 0.5;
// Handle `0` as a valid input
this.tension = (tension === 0 || tension) ? tension : defaultTension;
Three.js version
  • 0.109.0
Browser
  • [x] All of them
OS
  • [x] All of them
Bug

Most helpful comment

Nice find. We use this pattern to fix that:

this.tension = ( tension !== undefined ) ? tension : 0.5;

Would you like to file a PR and fix it?

>All comments

Nice find. We use this pattern to fix that:

this.tension = ( tension !== undefined ) ? tension : 0.5;

Would you like to file a PR and fix it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clawconduce picture clawconduce  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

Bandit picture Bandit  路  3Comments

jlaquinte picture jlaquinte  路  3Comments

filharvey picture filharvey  路  3Comments