Skip to content

Rendering polygon #162

Answered by rev111
rev111 asked this question in Q&A
Discussion options

You must be logged in to vote

I should have examined the examples. The box example shows how it's done with ie Pixi:

// Transfer positions of the physics objects to Pixi.js
graphics.position.x = boxBody.position[0]
graphics.position.y = boxBody.position[1]
graphics.rotation = boxBody.angle

So I have to send the angle to the client-side renderer as well, the polygon vertices appear to have an initial position with angle=0 and never change. The client renders this initial polygon and rotates it afterwards.
That makes me wonder: In order to calculate collisions and impacts, p2 needs to do a new rotation calculation for each body on each step, no? Then it seems to calculate a new angle and writes this new angle in the bo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rev111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant