简体   繁体   中英

How Disable ARcore Sceneform Lighting?

Base on ARcore Develop Guide ( Lighting Estimation developer guide for Android ), I am trying disable the light in the Scenceform. But nothing happen.

 arFragment.setOnTapArPlaneListener(
            (HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {
                if (objectRenderable == null) return;
                // Create the Anchor.
                Anchor anchor = hitResult.createAnchor();
                AnchorNode anchorNode = new AnchorNode(anchor);
                anchorNode.setParent(arFragment.getArSceneView().getScene());
                anchorNode.setSmoothed(true);
                objectRenderable.setShadowReceiver(false);
                objectRenderable.setShadowCaster(false);
                updateLight();
                TransformableNode transformableNode = new TransformableNode(arFragment.getTransformationSystem());
                transformableNode.getScaleController().setMaxScale(15.0f);
                transformableNode.getScaleController().setMinScale(1.0f);
                transformableNode.setParent(anchorNode);
                transformableNode.setRenderable(objectRenderable);
                transformableNode.select();
            });

private void updateLight() {
    Session session = new Session(this);
    // Configure the session with the Lighting Estimation API turned off.
    Config config = session.getConfig();
    config.setLightEstimationMode(Config.LightEstimationMode.DISABLED);
    session.configure(config);
}

The problem looks like I can not get the context session, science I got error " E/ARCore-AuthenticationManager: Exception during AuthenticationManager construction: com.google.android.gms.common.GoogleApiAvailability java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability"

You should get your current session and change it instead, try this:

class AppArFragment : ArFragment() {
    fun disableLight() {
        arSceneView.session?.apply {
            val changedConfig = config
            changedConfig.lightEstimationMode = Config.LightEstimationMode.DISABLED
            configure(changedConfig)
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM