package com.seewo.factoryaging.opengl3d.i;

import android.app.Activity;
import android.net.Uri;
import android.os.SystemClock;
import android.util.Log;
import com.seewo.factoryaging.opengl3d.i.b;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: compiled from: SceneLoader.java */
/* JADX INFO: loaded from: classes.dex */
public class c implements b.a {
    private Activity a;
    private com.seewo.factoryaging.opengl3d.d b;
    private com.seewo.factoryaging.opengl3d.h.e e;
    private final float[] t;
    private final com.seewo.factoryaging.opengl3d.j.c u;
    private com.seewo.factoryaging.opengl3d.h.c v;
    private boolean w;
    private Uri x;
    private a y;
    private List<com.seewo.factoryaging.opengl3d.j.c> c = new ArrayList();
    private boolean d = false;
    private boolean f = true;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private boolean f345g = false;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private boolean f346h = false;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private boolean f347i = false;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private boolean f348j = true;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private boolean f349k = false;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private boolean f350l = true;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private boolean f351m = true;
    private boolean n = true;
    private boolean o = false;
    private boolean p = false;
    private boolean q = false;
    private boolean r = false;
    private boolean s = false;

    public c(Uri uri, Activity activity, com.seewo.factoryaging.opengl3d.d dVar) {
        float[] fArr = {0.0f, 0.0f, 6.0f, 1.0f};
        this.t = fArr;
        com.seewo.factoryaging.opengl3d.j.c cVarD = com.seewo.factoryaging.opengl3d.j.b.d(fArr);
        cVarD.T("light");
        this.u = cVarD;
        this.v = new com.seewo.factoryaging.opengl3d.h.c();
        this.x = uri;
        this.a = activity;
        this.b = dVar;
    }

    private void B() {
        this.b.requestRender();
    }

    private void f() {
        this.e.i(0.0025f, 0.0f);
    }

    private void g() {
        if (this.f350l) {
            this.u.X(((int) (SystemClock.uptimeMillis() % 5000)) * 0.072f);
        }
    }

    public void A() {
        g();
        this.e.b();
        if (!this.w) {
            f();
        }
        if (!this.c.isEmpty() && this.n) {
            for (int i2 = 0; i2 < this.c.size(); i2++) {
                this.v.i(this.c.get(i2), x());
            }
        }
    }

    @Override // com.seewo.factoryaging.opengl3d.i.b.a
    public void a() {
        com.seewo.factoryaging.opengl3d.k.a.e(this.a);
    }

    @Override // com.seewo.factoryaging.opengl3d.i.b.a
    public void b(List<com.seewo.factoryaging.opengl3d.j.c> list) {
        for (com.seewo.factoryaging.opengl3d.j.c cVar : list) {
            if (cVar.D() == null && cVar.E() != null) {
                Log.i("LoaderTask", "Loading texture... " + cVar.E());
                try {
                    InputStream inputStreamC = com.seewo.factoryaging.opengl3d.k.a.c(cVar.E());
                    if (inputStreamC != null) {
                        try {
                            cVar.a0(com.seewo.factoryaging.opengl3d.k.c.a(inputStreamC));
                        } catch (Throwable th) {
                            if (inputStreamC != null) {
                                try {
                                    inputStreamC.close();
                                } catch (Throwable th2) {
                                    th.addSuppressed(th2);
                                }
                            }
                            throw th;
                        }
                    }
                    if (inputStreamC != null) {
                        inputStreamC.close();
                    }
                } catch (IOException unused) {
                    cVar.a("Problem loading texture " + cVar.E());
                }
            }
        }
        ArrayList arrayList = new ArrayList();
        for (com.seewo.factoryaging.opengl3d.j.c cVar2 : list) {
            e(cVar2);
            arrayList.addAll(cVar2.j());
        }
        com.seewo.factoryaging.opengl3d.k.a.e(null);
    }

    @Override // com.seewo.factoryaging.opengl3d.i.b.a
    public void c(int i2, String str) {
        a aVar = this.y;
        if (aVar == null) {
            return;
        }
        aVar.a(str);
    }

    @Override // com.seewo.factoryaging.opengl3d.i.b.a
    public void d(Exception exc) {
        Log.e("SceneLoader", exc.getMessage(), exc);
        com.seewo.factoryaging.opengl3d.k.a.e(null);
    }

    synchronized void e(com.seewo.factoryaging.opengl3d.j.c cVar) {
        ArrayList arrayList = new ArrayList(this.c);
        arrayList.add(cVar);
        this.c = arrayList;
        B();
    }

    public com.seewo.factoryaging.opengl3d.h.e h() {
        return this.e;
    }

    public com.seewo.factoryaging.opengl3d.j.c i() {
        return this.u;
    }

    public float[] j() {
        return this.t;
    }

    public synchronized List<com.seewo.factoryaging.opengl3d.j.c> k() {
        return this.c;
    }

    public void l(a aVar) {
        this.y = aVar;
        com.seewo.factoryaging.opengl3d.h.e eVar = new com.seewo.factoryaging.opengl3d.h.e();
        this.e = eVar;
        eVar.g(true);
        if (this.x == null) {
            return;
        }
        Log.i("Object3DBuilder", "Loading model " + this.x + ". async and parallel..");
        new e(this.a, this.x, this).execute(new Void[0]);
    }

    public boolean m() {
        return this.r;
    }

    public boolean n() {
        return this.f;
    }

    public boolean o() {
        return this.n;
    }

    public boolean p() {
        return this.d;
    }

    public boolean q() {
        return this.f349k;
    }

    public boolean r() {
        return this.f351m;
    }

    public boolean s() {
        return this.f347i;
    }

    public boolean t() {
        return this.f346h;
    }

    public boolean u() {
        return this.p;
    }

    public boolean v() {
        return this.f348j;
    }

    public boolean w() {
        return this.f345g;
    }

    public boolean x() {
        return this.o;
    }

    public boolean y() {
        return this.q;
    }

    public boolean z() {
        return this.s;
    }
}
