66import static com .ss .rlib .util .FileUtils .getExtension ;
77import static com .ss .rlib .util .ObjectUtils .notNull ;
88import com .jme3 .asset .AssetManager ;
9+ import com .jme3 .asset .AssetNotFoundException ;
910import com .jme3 .environment .generation .JobProgressAdapter ;
1011import com .jme3 .light .DirectionalLight ;
1112import com .jme3 .light .LightProbe ;
1415import com .jme3 .math .Vector3f ;
1516import com .jme3 .renderer .Camera ;
1617import com .jme3 .renderer .RenderManager ;
18+ import com .jme3 .renderer .RendererException ;
1719import com .jme3 .renderer .ViewPort ;
1820import com .jme3 .scene .Geometry ;
1921import com .jme3 .scene .Node ;
3133import com .ss .editor .executor .impl .EditorThreadExecutor ;
3234import com .ss .editor .model .tool .TangentGenerator ;
3335import com .ss .editor .ui .scene .EditorFXScene ;
36+ import com .ss .editor .util .EditorUtil ;
37+ import com .ss .rlib .logging .Logger ;
38+ import com .ss .rlib .logging .LoggerManager ;
3439import com .ss .rlib .ui .util .FXUtils ;
3540import com .ss .rlib .util .array .Array ;
3641import com .ss .rlib .util .array .ArrayFactory ;
4853 */
4954public class JMEFilePreviewManager extends AbstractControl {
5055
56+ @ NotNull
57+ private static final Logger LOGGER = LoggerManager .getLogger (JMEFilePreviewManager .class );
58+
5159 @ NotNull
5260 private static final Vector3f LIGHT_DIRECTION = new Vector3f (0.007654993F , 0.39636374F , 0.9180617F ).negate ();
5361
@@ -238,11 +246,20 @@ private void showObject(@NotNull final String path) {
238246 camera .setLocation (CAMERA_LOCATION );
239247 camera .setRotation (CAMERA_ROTATION );
240248
249+ modelNode .detachAllChildren ();
250+
241251 final AssetManager assetManager = EDITOR .getAssetManager ();
242252 final Spatial model = assetManager .loadModel (path );
253+ try {
243254
244- modelNode .detachAllChildren ();
245- modelNode .attachChild (model );
255+ final RenderManager renderManager = EDITOR .getRenderManager ();
256+ renderManager .preloadScene (model );
257+
258+ modelNode .attachChild (model );
259+
260+ } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e ) {
261+ EditorUtil .handleException (LOGGER , this , e );
262+ }
246263
247264 final Node rootNode = EDITOR .getPreviewNode ();
248265 rootNode .detachChild (modelNode );
@@ -266,10 +283,19 @@ private void showMaterial(@NotNull final String path) {
266283 final AssetManager assetManager = EDITOR .getAssetManager ();
267284 final Material material = assetManager .loadMaterial (path );
268285
286+ modelNode .detachAllChildren ();
287+
269288 testBox .setMaterial (material );
289+ try {
270290
271- modelNode .detachAllChildren ();
272- modelNode .attachChild (testBox );
291+ final RenderManager renderManager = EDITOR .getRenderManager ();
292+ renderManager .preloadScene (testBox );
293+
294+ modelNode .attachChild (testBox );
295+
296+ } catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e ) {
297+ EditorUtil .handleException (LOGGER , this , e );
298+ }
273299
274300 final Node rootNode = EDITOR .getPreviewNode ();
275301 rootNode .detachChild (modelNode );
0 commit comments