@@ -71,6 +71,9 @@ public class JMEFilePreviewManager extends AbstractControl {
7171 @ NotNull
7272 private static final Array <String > JME_FORMATS = ArrayFactory .newArray (String .class );
7373
74+ @ NotNull
75+ private static final Array <String > MODELS_FORMATS = ArrayFactory .newArray (String .class );
76+
7477 @ NotNull
7578 private static final Array <String > AUDIO_FORMATS = ArrayFactory .newArray (String .class );
7679
@@ -80,6 +83,9 @@ public class JMEFilePreviewManager extends AbstractControl {
8083 AUDIO_FORMATS .add (FileExtensions .AUDIO_OGG );
8184 AUDIO_FORMATS .add (FileExtensions .AUDIO_MP3 );
8285 AUDIO_FORMATS .add (FileExtensions .AUDIO_WAV );
86+ MODELS_FORMATS .add (FileExtensions .JME_OBJECT );
87+ MODELS_FORMATS .add (FileExtensions .MODEL_BLENDER );
88+ MODELS_FORMATS .add (FileExtensions .MODEL_GLTF );
8389 }
8490
8591 @ NotNull
@@ -105,6 +111,32 @@ public class JMEFilePreviewManager extends AbstractControl {
105111 return notNull (instance );
106112 }
107113
114+ /**
115+ * Check the file.
116+ *
117+ * @param file the file
118+ * @return true is the file is a file of a model.
119+ */
120+ @ FromAnyThread
121+ public static boolean isModelFile (@ Nullable final Path file ) {
122+ if (file == null ) return false ;
123+ final String extension = getExtension (file );
124+ return MODELS_FORMATS .contains (extension );
125+ }
126+
127+ /**
128+ * Check the file by the asset path.
129+ *
130+ * @param assetPath the asset path.
131+ * @return true is the file is a file of a model.
132+ */
133+ @ FromAnyThread
134+ public static boolean isModelFile (@ Nullable final String assetPath ) {
135+ if (StringUtils .isEmpty (assetPath )) return false ;
136+ final String extension = getExtension (assetPath );
137+ return MODELS_FORMATS .contains (extension );
138+ }
139+
108140 /**
109141 * Check the file.
110142 *
@@ -241,7 +273,7 @@ protected void controlRender(@NotNull final RenderManager renderManager, @NotNul
241273 }
242274
243275 /**
244- * Show a file.
276+ * Show the file.
245277 *
246278 * @param file the file.
247279 * @param fitWidth the target width of preview.
@@ -258,6 +290,20 @@ public void show(@NotNull final Path file, final int fitWidth, final int fitHeig
258290 showPreview (path , getExtension (assetFile ));
259291 }
260292
293+ /**
294+ * Show the external file.
295+ *
296+ * @param file the file.
297+ * @param fitWidth the target width of preview.
298+ * @param fitHeight the target height of preview.
299+ */
300+ @ FromAnyThread
301+ public void showExternal (@ NotNull final Path file , final int fitWidth , final int fitHeight ) {
302+ imageView .setFitHeight (fitHeight );
303+ imageView .setFitWidth (fitWidth );
304+ showPreview (file .toString (), getExtension (file ));
305+ }
306+
261307 /**
262308 * Show a preview of the file by the asset path.
263309 *
@@ -268,7 +314,7 @@ public void show(@NotNull final Path file, final int fitWidth, final int fitHeig
268314 private void showPreview (@ NotNull final String path , @ NotNull final String extension ) {
269315 if (FileExtensions .JME_MATERIAL .equals (extension )) {
270316 EDITOR_THREAD_EXECUTOR .addToExecute (() -> showMaterial (path ));
271- } else if (FileExtensions . JME_OBJECT . equals ( extension )) {
317+ } else if (isModelFile ( path )) {
272318 EDITOR_THREAD_EXECUTOR .addToExecute (() -> showObject (path ));
273319 } else {
274320 EDITOR_THREAD_EXECUTOR .addToExecute (this ::clear );
@@ -384,9 +430,8 @@ private void clearImpl() {
384430 *
385431 * @return the image view with a preview.
386432 */
387- @ NotNull
388433 @ FXThread
389- public ImageView getImageView () {
434+ public @ NotNull ImageView getImageView () {
390435 return imageView ;
391436 }
392437
@@ -395,8 +440,8 @@ public ImageView getImageView() {
395440 *
396441 * @return the transfer processor.
397442 */
398- @ NotNull
399- private FrameTransferSceneProcessor prepareScene () {
443+ @ JMEThread
444+ private @ NotNull FrameTransferSceneProcessor prepareScene () {
400445
401446 final Editor editor = Editor .getInstance ();
402447 final AssetManager assetManager = editor .getAssetManager ();
0 commit comments