asdf asdf - 5 months ago 58
Javascript Question

ThreeJS material.setValues is not a function

I'm starting out using three.js and I'm getting an error in

THREE.MeshLambertMaterial();
where


this.setValues is not a function



in this block of threejs' source code:

three.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 );

};


Coming from this call in my javascript:

graphics.js

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


Does anyone have any experience with this error and/or know what could be causing it?

Answer

Use the keyword new when creating a new Material or Geometry:

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

Side note: you can see the version number of your release by typing in the console THREE.REVISION or just looking at the top inside the file three.js / three.min.js.

Comments