flutter - 放入 ArCore 世界后编辑对象大小
问题描述
我正在尝试在 ArCore 环境中编辑一个 AR 立方体,因为它已经被放置在一个颤振环境(学校项目)中。
在制作对象时,这在代码中也是可见的:
import 'package:vector_math/vector_math_64.dart' as vector; /// Adding the import here because it's named one
final material = ArCoreMaterial(
color: Colors.accents[Random().nextInt(14)],
metallic: 0,
roughness: 1,
);
final cube = ArCoreCube(
materials: [material],
size: vector.Vector3(0.5, 0.5, 0.5),
);
final node = ArCoreNode(
shape: cube,
position: plane.pose.translation + vector.Vector3(0, 0.25, 0),
rotation: plane.pose.rotation
);
arCoreController.addArCoreNodeWithAnchor(node);
能够在颤振中使用 ArCore的插件本身有一个关于如何在运行时编辑材质的示例:
final material = ArCoreMaterial(
color: color,
metallic: metallic,
roughness: roughness,
reflectance: reflectance,
);
sphereNode.shape.materials.value = [material];
正如您从上面的结构中看到的那样,它与图片中的相同。
但是,当尝试编辑 vector3 的大小时,我无法对其进行编辑。
object.shape.size.value = vector.Vector3(25, 25, 25); /// Class 'Vector3' has no instance setter 'value='.
object.shape.size.value = [ vector.Vector3(25, 25, 25) ]; /// Class 'Vector3' has no instance setter 'value='.
object.shape.size = vector.Vector3(25, 25, 25); /// Class 'ArCoreCube' has no instance setter 'size='.
object.shape.size._value = vector.Vector3(25, 25, 25); /// Class 'Vector3' has no instance setter '_value'.
这些都失败了。
我也尝试过使用比例:
object.scale.value = vector.Vector3(0.25, 0.25, 0.25); /// No error, no visual change
object.scale.value = vector.Vector3(25, 25, 25); /// No error, no visual change
object.scale.value = [ vector.Vector3(25, 25, 25) ]; /// type 'List<Vector3>' is not a subtype of type 'Vector3' of 'newValue'
虽然我没有得到正确比例属性的错误,但它们不会改变,而对象上的材料会改变。
解决方案
推荐阅读
- lua - Roblox Studio Lua:商店屏幕 Gui:按钮未显示
- c++ - 在字符串c ++中存储多个十六进制值
- python - Python Pandas 有条件的只执行第一个“If”语句
- python - 检查元素与 BeautifulSoup/Selenium 返回的元素不同
- coldfusion - 是否有与单个 ColdFusion 请求相关的易于访问的唯一 ID?
- php - PHP - 带有特殊字符的 utf8_decode 是小写的
- python - python:用另一个列表中的项目索引替换列表项目
- wordpress - .htacces 和非 www www 重定向
- ruby-on-rails - 代表 has_many :though with Factory Bot
- java - 从 Matlab 调用 Java 类时找不到记录器的附加程序