vec.mulScalar is not a function?

I’m trying out a Vec3 function in the API. (I’m using the engine only). Here’s my code:

  var vec = new pc.Vec3(120,11,-2);
  light1.setPosition(vec.mulScalar(3));

and it won’t compile because it says:

TypeError: vec.mulScalar is not a function

Do I need to download another library or something?

Hi @Michael_McCrickard,

That seems like a bug, there was a refactoring of the math vector class. Try raising an issue about it on the engine repo.

are you using up to date engine? This was added recently, and it works for me, I’ve use it few times in the last few days.

2 Likes

This is how I’m getting the PC script:

<script src='https://cdnjs.cloudflare.com/ajax/libs/playcanvas/1.39.1/playcanvas.js'></script>

Is there a different link that would always point to the latest version?

Hi @Michael_McCrickard,

Yes, that’s an older version of the engine, not sure how you got that url.

You can find the latest dev and stable releases here:

Unless you have a certain reason to use a dev release, always use the stable one and preferably the minified url:

https://code.playcanvas.com/playcanvas-stable.min.js
3 Likes