javascript - Three js Object 3D rotation -


hy! i'm facing strange problem in 3 js(r71) / threex (threex.laserbeam). i'm having problems rotation of object 3d.

i'm calculating latitude, attitude points phi,theta this: (or other variables 50/-51)

var phi = (90 - 50) * math.pi / 180; var theta = (-51) * math.pi / 180; 

after drop sphere on location following code:

var geometry = new three.spheregeometry( 0.005, 15, 15 ); var material = new three.meshbasicmaterial( {color: 0x0000ff} ); var sphere = new three.mesh( geometry, material );  scene.add( sphere );  sphere.position.x = 0.5 * math.sin(phi) * math.cos(theta); sphere.position.y = 0.5 * math.cos(phi); sphere.position.z = 0.5 * math.sin(phi) * math.sin(theta); 

then rotate ray same position following code:

laserbeam.rotation.y = -theta laserbeam.rotation.z = phi 

the laserbeam acts "line", in object3d. origin of ray @ (0,0). haven't got faintest idea why not going trough sphere (see screenshot).

any ideas?

---edit--- or here example simple line

var phi = (90 - 50) * math.pi / 180; var theta = (-51) * math.pi / 180; var geometry = new three.geometry(); geometry.vertices.push(new three.vector3(0, 0, 0)); geometry.vertices.push(new three.vector3(1 * math.sin(phi) * math.cos(theta), 1* math.cos(phi), 1 * math.sin(phi) * math.sin(theta))); var material = new three.linebasicmaterial({                                     color: 0x0000ff                                 }); var line = new three.line(geometry, material); containerline   = new three.object3d(); containerline.add( line ); scene.add(containerline); 

you incorrectly calculates small radius , y-coordinates:

var rm = r * math.cos(phi); // vs `r * math.sin(phi)` sphere.position.x = rm * math.cos(theta); sphere.position.y = r * math.sin(phi); // vs `r * math.cos(phi)` sphere.position.z = rm * math.sin(theta); 

http://jsfiddle.net/sxen2kld/


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -