What if onTransform MatrixChangedObservable

Hi, I want to make some computations only when camera moved or size of canvas changed. Is it nice approach? :thinking:

let cacheMatrix = this._scene.getTransformMatrix().clone();
this._scene.onBeforeRenderObservable.add((scene) => {
    let matrix = scene.getTransformMatrix();
    if (!matrix.equals(cacheMatrix)) {
        cacheMatrix = matrix.clone();
        this.onTransformMatrixChangedObservable.notifyObservers(cacheMatrix);
    }
});

You can maybe use the onViewMatrixChangedObservable and onProjectionMatrixChangedObservable observers on camera?

1 Like

Of course there is better solution. Mush thanks.