I’m learning Threejs by following this tutorial
I’m stuck at making the boilderplate. It got error: “Uncaught TypeError: Cannot read properties of undefined (reading ‘uniforms’).
In my code, i defined uniforms at:
<!-- language: lang-js -->
addObjects() {
this.material = new THREE.ShaderMaterial({
vertexShader: vertex,
fragmentShader: fragment,
extensions: {
derivatives:" #extension GL_OES_standard_derivatives: enable"
},
uniforms: {
time: {value:0},
resolution: {value: new THREE.Vector4()},
},
side: THREE.DoubleSide
});
this.geometry = new THREE.PlaneGeometry(1,1,1,1);
this.plane = new THREE.Mesh(this.geometry, this.material);
this.scene.add(this.plane);
}
Then, i called it in this block:
<!-- language: lang-js -->
render() {
if(!this.isPlaying) return;
this.time += 0.05;
this.material.uniforms.time.value = this.time;
requestAnimationFrame(this.render.bind(this));
this.renderer.render(this.scene, this.camera);
}
What seem to be the problems here?