private void sceneDidChange() {
    assert this.scrollPane != null;

    if (scrollPane.getScene() != null) {
      assert scalingGroup.isVisible() == false;

      // Here we'd like to layout the user scene graph immediately
      // i.e. invoke:
      //      1) layoutContent()      // to relayout user scene graph
      //      2) adjustWorkspace()    // to size the content workspace
      //
      // However invoking layoutContent() from here (scene change listener)
      // does not work very well (see RT-32326).
      //
      // So we do these two steps in runLater().
      // Until they are done, scalingGroup is kept invisible to avoid
      // visual artifacts. After the two steps are done, we turn the
      // visible by calling revealScalingGroup().

      Platform.runLater(
          () -> {
            layoutContent(true /* applyCSS */);
            adjustWorkspace();
            revealScalingGroup();
          });
    } else {
      assert scalingGroup.isVisible();
      scalingGroup.setVisible(false);
    }
  }
  public void setAutoResize3DContent(boolean autoResize3DContent) {

    this.autoResize3DContent = autoResize3DContent;
    if ((scrollPane != null) && (scrollPane.getScene() != null)) {
      adjustWorkspace();
    }
  }