Use the geometry after having moved an objet

Hello,
I’d like to move an object in a 3D world then compute the intersection between this object and a plane.
The issue I’m faced with is that the geometry I get after having moved the object seems to be the geometry before the move.

The main part of my code is as follow:

			let currentObject2D = this.scene2D.getObjectByName(nom)
			if (currentObject2D !== undefined) {
				if (currentObject2D.position.y < 30) {
					currentObject2D.position.y += 1
					currentObject2D.updateMatrix()
				}

Then:

const objetPositionAttribute = currentObject2D.geometry.getAttribute('position')
for (let vertexIndex = 0; vertexIndex < objetPositionAttribute.count; vertexIndex += 3) {
				localVertex.fromBufferAttribute(objetPositionAttribute, vertexIndex)
				objet.localToWorld(a.copy(localVertex))

Here the a vector is the position of this array before the translation.

Should I use promises?
Can you explain what I’m doing wrong please?

None of the functions in the snippets are asynchronous - so promises don’t seem necessary.

  1. There seems to be quite a few typos.
  2. It’s a bit hard to understand what the code does overall - the snippets seem disconnected and have no result :sweat_smile: Could you maybe try to replicate the issue codepen, or share a bit more of the related code?

Hi, thanks for the reply.
Sorry to haven’t been clear enough.

The problem was that le matrix used when I use the “localToWorld” matrix that I updated in the first snippet of code.
I added an this.scene2D.updateMatrixWorld(true) after the updateMatrix() and everything working fine now.

By the way, you have some pretty impressive collection of sample code in your codepen repo.