Transform global position to local

I’m trying to convert global coordinates of “particles” to the local positon of a Points object moving around the scene.

Attempts to apply the object’s matrix and using worldToLocal are not working properly:

local = globalParticle.position.clone().applyMatrix4( movingPointsObject.matrixWorld.invert() );


local = movingPointsObject.worldToLocal( globalParticle.position );


Minimal example:

The former works in conjunction with

  movingPointsObject.updateWorldMatrix(true, true);

Inspired by worldToLocal, see three.js/Object3D.js at 03349e98aa1f57a97433c0a3f17697594fdc0997 · mrdoob/three.js · GitHub

Still, an explanation and or improvements would be appreciated!