Mesh Has a Defined Offset in my Program

I am creating a visualization for my evolution simulation and I have an odd problem which I already suspect the reason for. Each organism is represented by the wireframe mesh which is initialized with the following callback.

export const organismObject = (position, size, color=0xf55a42, userData) => {
    //todo add parameter with species decorations/style map and generatively creates a unique design

    //const geometry = new THREE.BoxGeometry(size, size, size);
    const geometry = new THREE.ShapeGeometry( 
        new THREE.Shape([ 
            new THREE.Vector2(0, 0), 
            new THREE.Vector2(size/2, 0),
            new THREE.Vector2(size/2, size),
            new THREE.Vector2(size/4, 1.25*size), 
            new THREE.Vector2(0, size) 
    const material = new THREE.MeshBasicMaterial({color: color, wireframe: true });
    const cube = new THREE.Mesh(geometry, material);
    cube.rotation.set(0, 0, 0);
    cube.scale.set(1, 1, 1);

    const group = new THREE.Group().add(cube);
    group.matrixAutoUpdate = true;

    group.userData = userData || {};

    return group;


Which is called by the constructor of my OrganismObject class with the position being [organism.x, organism.y, 0].

Now during rendering, the meshes seem “ahead” visually of its own data while wandering. This disparity was demonstrated by the mesh not clipping within the boundaries of the box until a certain offset. To confirm this I made sure that the data upon being updated created a "trail’ of its coordinates. Here is what I see:

The trails show it as far off, but by an even factor. And the trails never escape (as they shouldn’t), but the organisms do. What could be the problem?

Is it that setting the mesh’s position to the organism’s position is the problem? If so, how would I make it so that the object starts on the coordinates it needs to be on without this offset?

Also another weird thing, my Mesh starts at the correct position, but quickly leaves shown by the following at frame 1.
And the next by frame 2.

OrthographicCamera may possibly solve your problem :eyes:? Sounds to me like you’re trying to fight the perspective right now, so maybe no point in having perspective at all?

1 Like