Three.js 多属性组件的setAttribute不适用于vec3

Three.js 多属性组件的setAttribute不适用于vec3,three.js,aframe,setattribute,Three.js,Aframe,Setattribute,我试图通过以下代码向实体添加多属性组件- 在a帧场景中- <a-entity id="hornets"></a-entity> 该组件的代码如下所示: AFRAME.registerComponent('crtmodelcopy', { schema: { id: {type:'string'}, jitter: {type:'vec3'}, modelCenter: {type:'vec3'},

我试图通过以下代码向实体添加多属性组件-

在a帧场景中-

<a-entity id="hornets"></a-entity>
该组件的代码如下所示:

AFRAME.registerComponent('crtmodelcopy', {
  schema: {
          id: {type:'string'},
          jitter: {type:'vec3'},
          modelCenter: {type:'vec3'},
          src: {type:'string'}
          },
  init: function() {
          ......
   }
但是,我在控制台中得到以下错误-

Uncaught SyntaxError: Unexpected number
我无法理解我在这里做错了什么。我试过其他的组合,但没有用。在某些情况下,组件在没有任何属性的情况下被附加。我认为问题是由于抖动和modelCenter属性是vec3字段,所以我需要以相同的格式传递数据

有人能帮忙吗

谢谢,
Niraj

实际上,您没有传递一个
vec3
,只有三个数字是意外值,因为解析器需要一个向量


传递一个
vec3

setAttribute("test", {"jitter": new THREE.Vector3( 0, 1, 0 )})
或向量的字符串版本:

setAttribute("test", {"jitter": "0 1 0"})

看看吧。控制台显示这两个向量都正确地传递到了
更新
函数中。

感谢您的响应。我将setattribute代码改为-hornets.setattribute('crtmodelcopy',{“id”:“ball”,“jitter”:“51.20.4”,“modelCenter”:“20.5-50”,“src”:“hornet”});我是否应该将组件中的所有逻辑从init函数移到update函数以使其能够读取数据?这是个好主意,因为
update
在init和update(如setAttribute)上都被调用。您可以将逻辑移动到某些外部函数,并仅更新在更新中更改的变量
setAttribute("test", {"jitter": "0 1 0"})