react-p5 icon indicating copy to clipboard operation
react-p5 copied to clipboard

How can I access to p5.Vector class?

Open jersonlatorre opened this issue 3 years ago • 2 comments

I want to use p5.Vector class. How should I do that?

jersonlatorre avatar Aug 29 '22 02:08 jersonlatorre

Same question here, I'm using nextjs with typescript and getting the error: Property 'Vector' does not exist on type 'import("./node_modules/@types/p5/index.d.ts")'.

Even if I use window.p5.Vector as mentioned in this issue. I'm getting this error... Property 'p5' does not exist on type 'Window & typeof globalThis'.

codingholt avatar Aug 31 '22 12:08 codingholt

Update: window.p5.Vector does work but gives above error in my ide. So I added

declare global {
    interface Window { p5: p5Types; }
}

I'm now getting this type error again: Property 'Vector' does not exist on type 'import("./node_modules/@types/p5/index.d.ts")'.

So I think the Vector type need to be added to p5Types, anyway it is working sort of for me now.

codingholt avatar Sep 01 '22 15:09 codingholt

I ran into the same problem: p5.constructor.Vector does the job !

matteo-dirollo avatar Sep 26 '22 16:09 matteo-dirollo