gpt4 book ai didi

javascript - ThreeJS Material.setValues 不是函数

转载 作者:行者123 更新时间:2023-11-28 15:08:44 25 4
gpt4 key购买 nike

我开始使用 Three.js,但在 THREE.MeshLambertMaterial(); 中遇到错误,其中

this.setValues is not a function

在这 block Threejs 的源代码中:

三.js

THREE.MeshLambertMaterial = function ( parameters ) {

THREE.Material.call( this );

this.type = 'MeshLambertMaterial';

this.color = new THREE.Color( 0xffffff ); // diffuse

this.map = null;

this.lightMap = null;
this.lightMapIntensity = 1.0;

this.aoMap = null;
this.aoMapIntensity = 1.0;

this.emissive = new THREE.Color( 0x000000 );
this.emissiveIntensity = 1.0;
this.emissiveMap = null;

this.specularMap = null;

this.alphaMap = null;

this.envMap = null;
this.combine = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;

this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';

this.skinning = false;
this.morphTargets = false;
this.morphNormals = false;

--> this.setValues( parameters );

};

来 self 的 javascript 中的此调用:

graphics.js

var sphereMaterial = THREE.MeshLambertMaterial(
{color: 0x55B663});

有人有过此错误的经验和/或知道可能导致此错误的原因吗?

最佳答案

创建新 Material 或几何图形时使用关键字new:

var sphereMaterial = new THREE.MeshLambertMaterial({color: 0x55B663});

旁注:您可以通过在控制台中输入 THREE.REVISION 或仅查看文件 Three.js 的顶部来查看版本号/two.min.js.

关于javascript - ThreeJS Material.setValues 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37639667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com