我正在遵循谷歌开发人员指南,将灯光添加到 SceneView 中的节点:
https://developers.google.com/sceneform/develop/build-scene
Light spotLightYellow =
Light.builder(this, Light.Type.FOCUSED_SPOTLIGHT)
.setColor(new Color(android.graphics.Color.YELLOW))
.setShadowCastingEnabled(true)
.build();
但是它似乎对我的渲染模型没有任何作用。
我还有什么遗漏的吗?
ModelRenderable.builder()
.setSource(
this,
Uri.parse(card)
)
.build()
.thenAccept(
modelRenderable -> {
node.setParent(scene);
node.setLocalPosition(vector3);
node.setLocalScale(new Vector3(1.4f, 1.4f, 1.4f));
node.setName("Test");
Light light =
Light.builder(Light.Type.FOCUSED_SPOTLIGHT)
.setColor(new Color(android.graphics.Color.YELLOW))
.setShadowCastingEnabled(true)
.build();
node.setLight(light);
node.setRenderable(modelRenderable);
})
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load Fox renderable" + throwable, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
确保
DIRECTIONAL
光的强度远低于 FOCUSED_SPOTLIGHT
的强度。聚光灯的位置和方向确实很重要,但是定向光仅受方向控制(正如其名称所示)。如果 FOCUSED_SPOTLIGHT
仍然不起作用,请尝试常规 SPOTLIGHT
。