Thank you for your answer, I did what you told me, it is working fine!
const ofun = vtkPiecewiseFunction.newInstance();
ofun.addPoint(0, 1);
ofun.addPoint(150, 1);
ofun.addPoint(180, 0);
ofun.addPoint(255, 0);
obj.resliceActor1.getProperty().setPiecewiseFunction(ofun)