mix加入第三个参数后报错
来源:17-7 给建筑物添加渐变色
慕虎6433011
2023-05-11
为什么我这里mix加入第三个参数后报错呢?let size = 100 new FBXLoader().load('/beijing.fbx', (e) => { e.traverse(c => { if (c.isMesh) { console.log(c); c.geometry.computeBoundingBox() c.geometry.computeBoundingSphere() const { max, min } = c.geometry.boundingBox size = max.z - min.z const mate = new THREE.ShaderMaterial({ uniforms: { uCityColor: { value: new THREE.Color('#ffffff') }, uheaderColor: { value: new THREE.Color('#183045') }, uSize: { value: size } }, vertexShader:
varying vec3 vheight;
void main(){
vheight = position;
gl_Position=projectionMatrix * modelViewMatrix *vec4(position,1.0);
}, fragmentShader:
precision mediump float;
varying vec3 vheight;
uniform vec3 uCityColor;
uniform vec3 uheaderColor;
uniform vec3 uSize;
void main(){
vec3 baseColor =uCityColor;
baseColor = mix(uCityColor, uheaderColor,vheight.z/uSize);
// gl_FragColor=vec4( 1.0,0.0,0.0,1.0) ;
gl_FragColor=vec4(baseColor,1.0) ;
}
`,
})
let mesh = new THREE.Mesh(c.geometry, mate)
mesh.position.copy(c.position)
mesh.rotation.copy(c.rotation)
mesh.scale.copy(c.scale)
this.scene.add(mesh)
}
})
})`
1回答
-
uSize是vec3的类型,不是浮点数,类型不一致
00
相似问题