#1340·matter-js

Problem and fix for `constraint.render.type: 'pin'` in non-minimized code for version 0.20.0.

Author: VaiokCreated Apr 18, 2025Updated Apr 18, 2025

This is for the non-minimized code of version 0.20.0.

Description

The pin type for constraint rendering is causing an error in the Render.constraints function because end.x and end.y are only defined in the else block when the if condition testing constraint.render.type === 'pin' fails. The following code

javascript
if (bodyB) {
    end = Vector.add(bodyB.position, constraint.pointB);
} else {
    end = constraint.pointB;
}

should be moved out of the else condition and put directly beneath this code.

javascript
if (bodyA) {
    start = Vector.add(bodyA.position, constraint.pointA);
} else {
    start = constraint.pointA;
}

Images

Console Error:

Image

Place in Code Indicated by the Error Output:

Image

Place in Code Where the Problem is Before Fixed:

Image

Place in Code Where the Problem is After Fixed:

Image