Thread safe

In Chapter 7, 360-Degree Gallery, we explained the need for worker threads to offload processing from the render thread. In this project, we'll add threading to the ModelObject constructor where we read and parse the model files:

 public ModelObject(final int objFile) { super(); extentsMin = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); extentsMax = new Vector3(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); SolidColorLightingMaterial.setupProgram(); enabled = false; new Thread(new Runnable() { @Override public void run() { InputStream inputStream = RenderBox.instance.mainActivity.getResources().openRawResource(objFile); if (inputStream == null) return; // error createMaterial(); enabled = true; float scalar = ...

Get Cardboard VR Projects for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.