11package app .f3d .F3D .android ;
22
33import android .content .Context ;
4+ import android .net .Uri ;
45import android .opengl .GLSurfaceView ;
56import android .util .Log ;
67import android .view .MotionEvent ;
78import android .view .ScaleGestureDetector ;
89
10+ import java .io .IOException ;
11+ import java .io .InputStream ;
912import java .util .Objects ;
1013
1114import javax .microedition .khronos .egl .EGLConfig ;
@@ -19,7 +22,7 @@ public class MainView extends GLSurfaceView {
1922 final private ScaleGestureDetector mScaleDetector ;
2023 final private PanGestureDetector mPanDetector ;
2124 final private RotateGestureDetector mRotateDetector ;
22- private String internalCachePath = "" ;
25+ private Uri mActiveUri = Uri . EMPTY ;
2326
2427 public MainView (Context context ) {
2528 super (context );
@@ -66,14 +69,23 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
6669 MainView .this .mEngine .getOptions ().toggle ("ui.loader_progress" );
6770// MainView.this.mEngine.getOptions().toggle("model.volume.enable");
6871
69- if (!Objects .equals (internalCachePath , "" )) {
70- MainView .this .mEngine .getScene ().add (internalCachePath );
72+ if (!Objects .equals (mActiveUri , Uri .EMPTY )) {
73+ try (InputStream inputStream = MainView .this .getContext ().getContentResolver ().openInputStream (mActiveUri )) {
74+ if (inputStream != null ) {
75+ byte [] fileBytes = new byte [inputStream .available ()];
76+ inputStream .read (fileBytes );
77+
78+ MainView .this .mEngine .getScene ().addBuffer (fileBytes , fileBytes .length );
79+ }
80+ } catch (IOException e ) {
81+ e .printStackTrace ();
82+ }
7183 }
7284 }
7385 }
74- public void updateFilePath ( String newFilePath ) {
86+ public void updateActiveUri ( Uri uri ) {
7587 // Use the new file path as needed in MainView
76- internalCachePath = newFilePath ;
88+ mActiveUri = uri ;
7789 }
7890
7991 private class ScaleListener extends ScaleGestureDetector .SimpleOnScaleGestureListener {
0 commit comments