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 = normalScalar(); transform.setLocalScale(scalar, scalar...