我正在遵循谷歌开发者指南关于如何在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;
});
.sfb
文件没有名为 lit 或 unlit 的键。但我注意到,场景中的默认太阳节点会照亮我的 3D 模型,否则在 Android Studio 3D 查看器中它就很暗。我现在正在尝试添加一个额外的光节点(FOCUSED_SPOTLIGHT),但对渲染的模型没有影响。 - DIRTY DAVE