java - 如何禁用 ARcore Sceneform Lighting?

标签 java android arcore sceneform

基于 ARcore 开发指南 ( Lighting Estimation developer guide for Android ),我正在尝试禁用 Scenceform 中的灯光。但什么也没发生。

 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);
}

问题看起来我无法获得上下文 session ,科学我得到错误“E/ARCore-AuthenticationManager:AuthenticationManager 构造期间的异常:com.google.android.gms.common.GoogleApiAvailability java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability"

最佳答案

您应该获取当前 session 并更改它,试试这个:

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

关于java - 如何禁用 ARcore Sceneform Lighting?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59057352/

相关文章:

Java 泛型错误 : Cannot convert from E to E?

java - 为什么代码会运行命令,即使其 if 语句未得到满足?

java - 如何处理数据库崩溃(Glassfish/MySQL)?

java - ARFragment 和 GLSurfaceView 在一个 Activity 中兼容吗?

java - 使用 Grid Bag Layout 调整按钮大小

android - 弹出后堆栈后,我的 fragment 没有被垃圾收集

android - 如何保存应用程序类状态

android - 如何在android中使用volley库调用graphql post请求

java - 如何使用 Arcore 截屏?

unity3d - 手机前置摄像头如何使用ARCore