In my implementation of a three.js mesh (found in three.js-master\examples\webgl_loader_collada_keyframe.html), I have a basic setup:
function init() {
...
...
var sphereGeometry = new THREE.SphereGeometry( 50, 32, 16 );
var sphereMaterial = new THREE.MeshLambertMaterial( {color: 0x8888ff} );
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
sphere.position.set(10, 10, 10);
scene.add(sphere);
I want to change the position of this mesh during the animation function;
I attempted different methods, but none of them were successful:
1.:
sphere.position.set = new THREE.Vector3(20, 20, 20);
2.:
sphere.position.set(20, 20, 20);
3.:
sphere.position.x += 1;
4.:
sphere.translateX(50);
Each attempt resulted in a blank screen.
Interestingly, changing camera and light positions in the same code block works fine:
pointLight.position.set(10, 20, 03);
camera.position.set(12, 44, 13);
camera.lookAt(new THREE.Vector3(33, 45, 54));
However, modifying a mesh's position using position.set fails. Is it feasible to alter a mesh's position within the animate function?
I tried:
"sphere.position.x = 20;"
which resulted in a black window.
Below is a detailed console log:
The error message for "sphere.position.x = 20;":
"Uncaught TypeError: Cannot set property 'x' of undefined"
Additional details from the log related to this issue:
"animate @ index_final.html:260
(anonymous function) @ index_final.html:98
parse @ ColladaLoader.js:225
request.onreadystatechange @ ColladaLoader.js:113"