无法读取未定义的属性“位置”

时间:2018-09-28 19:59:44

标签: javascript three.js glsl

我正在与THREE.js和glsl一起使用着色器。我正在尝试将此对象用于照明:

testDone

这是我想通过的制服:

function light(pos, color, intensity, rad){

      this.position = new THREE.Vector3(pos.x,pos.y,pos.z);
      this.clight = new THREE.Vector3(color.x,color.y,color.z);
      this.intensity = intensity;
      this.rad = rad;

    }

var light1 = new light(lightPosition,clight,inty,rad );

最后在片段着色器中使用此结构:

var floorUniform = {
      baseColor: {type: "t", value: loadTexture(floorPath + "baseColor.png")},
      normalMap: {type: "t", value: loadTexture(floorPath + "normalMap.png")},
      roughnessMap: {type: "t", value: loadTexture(floorPath + "roughnessMap.png")},
      metalnessMap: {type: "t", value: loadTexture(floorPath + "metalness.png")},
      diffuseMap: {type: "t", value: loadTexture(floorPath + "diffuseMap.png")},
      normalScale: {type: "v2", value: new THREE.Vector2(1,1)},
      textureRepeat: {type: "v2", value: new THREE.Vector2(8,8)},
      light: light1,
      envMap: {type: "t", value: envMap},
      aoMap: {type: "t", value: loadTexture(floorPath + "AmbientOcclusionMap.png")}
    };

因此,当我尝试读取position属性时,着色器会抛出错误: 未捕获的TypeError:无法读取未定义的属性“位置”

我不知道为什么,有人可以帮助我吗?

感谢您的咨询

0 个答案:

没有答案