Angular 三个js:属性';处置';不存在于类型';材料|材料[]和#x27;

Angular 三个js:属性';处置';不存在于类型';材料|材料[]和#x27;,angular,types,three.js,Angular,Types,Three.js,我有一个角度6.0.5运行三 所有人都在使用三个版本0.89.0和@types/three版本0.84.3 我已经更新到三个版本0.93.0和@types/three版本0.92.5 现在一切都坏了。我得到以下错误: Property 'dispose' does not exist on type 'Material | Material[]'. Property 'dispose' does not exist on type 'Material[]'. 及 及 及 我的猜测是类型和库不

我有一个角度6.0.5运行三

所有人都在使用三个版本0.89.0和@types/three版本0.84.3

我已经更新到三个版本0.93.0和@types/three版本0.92.5

现在一切都坏了。我得到以下错误:

Property 'dispose' does not exist on type 'Material | Material[]'.

Property 'dispose' does not exist on type 'Material[]'.


我的猜测是类型和库不兼容。有人知道如何解决这个问题吗?

我也遇到过这个问题。因为没有多重材质,所以必须使用材质数组。如果查看网格中“材质”的签名,它现在是: 材料|材料[] 因此,您无法将其作为材质直接访问。我所做的,假设您从未使用过材质数组,将被转换为,例如:

mesh1.material.dispose();  //error since material could be an array
(<any>mesh1.material).dispose();     //OK since it doesn't know what it is
mesh1.material.dispose()//错误,因为材质可能是数组
(1.材料)。处理()//好吧,因为它不知道它是什么
我认为一般的解决方案是检查数组并分别处理每种情况,但这会导致代码不好,所以可能有更好的解决方案


您的另一个问题是“着色”已更改为布尔“flatShading”。

您使用的是多重材质吗?如果是这样,您应该对数组中的每个材质执行
dispose
,而不是对数组本身。我在每个材质中调用dispose。这不是问题所在,它看起来更像是最新npm版本的three和最新npm版本的@types/three之间的不兼容。我需要知道三个和@types/three兼容的最新npm版本。
Property 'clippingPlanes' does not exist on type 'Material | 
Material[]'.

Property 'clippingPlanes' does not exist on type 'Material[]'.
Argument of type '{ shading: Shading; side: Side; shininess: number; 
color: number; transparent: true; opacity: num...' is not assignable 
to parameter of type 'MeshPhongMaterialParameters'.

Object literal may only specify known properties, and 'shading' does 
not exist in type 'MeshPhongMaterialParameters'.
mesh1.material.dispose();  //error since material could be an array
(<any>mesh1.material).dispose();     //OK since it doesn't know what it is