appoly / ARCore-Location

Allows items to be placed within the AR world with real-world GPS coordinates using ARCore.
https://www.appoly.co.uk/arcore-location/
MIT License
478 stars 158 forks source link

Rendering 3D model in version 1.2 makes the app to crash #92

Closed DarshnaDesai closed 5 years ago

DarshnaDesai commented 5 years ago

Rendering the "andy.sfb" model makes the app to crash with below error and code.

ERROR: E/Filament: Panic in Handle filament::details::FMaterial::getProgramSlow(uint8_t) const:294 reason: The material 'FBX Material' has not been compiled to include the required GLSL or SPIR-V chunks for the vertex shader (variant=0xd, filtered=0xd). 2019-04-26 10:53:12.672 29729-29729/com.arcoredemo E/Filament: --------- beginning of crash 2019-04-26 10:53:12.675 29729-29729/com.arcoredemo A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 29729 (com.arcoredemo)

CODE: // Build a renderable from a 2D View. CompletableFuture exampleLayout = ViewRenderable.builder() .setView(this, R.layout.example_layout) .build();

    // When you build a Renderable, Sceneform loads its resources in the background while returning
    // a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get().
    CompletableFuture<ModelRenderable> andy = ModelRenderable.builder()
            .setSource(this, R.raw.andy)
            .build();

    CompletableFuture.allOf(
            exampleLayout,
            andy)
            .handle(
                    (notUsed, throwable) -> {
                        // When you build a Renderable, Sceneform loads its resources in the background while
                        // returning a CompletableFuture. Call handle(), thenAccept(), or check isDone()
                        // before calling get().

                        if (throwable != null) {
                            DemoUtils.displayError(this, "Unable to load renderables", throwable);
                            return null;
                        }

                        try {
                            exampleLayoutRenderable = exampleLayout.get();
                            andyRenderable = andy.get();
                            hasFinishedLoading = true;

                        } catch (InterruptedException | ExecutionException ex) {
                            DemoUtils.displayError(this, "Unable to load renderables", ex);
                        }

                        return null;
                    });

    // Set an update listener on the Scene that will hide the loading message once a Plane is
    // detected.
    arSceneView
            .getScene()
            .addOnUpdateListener(
                    frameTime -> {
                        if (!hasFinishedLoading) {
                            return;
                        }

                        if (locationScene == null) {
                            // If our locationScene object hasn't been setup yet, this is a good time to do it
                            // We know that here, the AR components have been initiated.
                            locationScene = new LocationScene(this, arSceneView);

                            // Now lets create our location markers.
                            // First, a layout
                            LocationMarker layoutLocationMarker = new LocationMarker(
                                    lng,
                                    lat,
                                    getExampleView()
                            );

                            // An example "onRender" event, called every frame
                            // Updates the layout with the markers distance
                            layoutLocationMarker.setRenderEvent(new LocationNodeRender() {
                                @Override
                                public void render(LocationNode node) {
                                    View eView = exampleLayoutRenderable.getView();
                                    TextView distanceTextView = eView.findViewById(R.id.textView2);
                                    distanceTextView.setText(node.getDistance() + "M");
                                }
                            });
                            // Adding the marker
                            locationScene.mLocationMarkers.add(layoutLocationMarker);

                            // Adding a simple location marker of a 3D model
                            locationScene.mLocationMarkers.add(
                                    new LocationMarker(
                                            lng,
                                            lat,
                                            getAndy()));
                        }

                        Frame frame = arSceneView.getArFrame();
                        if (frame == null) {
                            return;
                        }

                        if (frame.getCamera().getTrackingState() != TrackingState.TRACKING) {
                            return;
                        }

                        if (locationScene != null) {
                            locationScene.processFrame(frame);
                        }

                        if (loadingMessageSnackbar != null) {
                            for (Plane plane : frame.getUpdatedTrackables(Plane.class)) {
                                if (plane.getTrackingState() == TrackingState.TRACKING) {
                                    hideLoadingMessage();
                                }
                            }
                        }
                    });

    // Lastly request CAMERA & fine location permission which is required by ARCore-Location.
    ARLocationPermissionHelper.requestPermission(this);
}
johnwedgbury commented 5 years ago

This would be better posted to https://github.com/google-ar/sceneform-android-sdk/issues