We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

how can i convert polarAngle, aziumthalAngle, and distance to vector3.

Home Forums Programming how can i convert polarAngle, aziumthalAngle, and distance to vector3.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #35864

    Hi, I need your help.
    I know that i can get polarAngle, aziumthalAngle from app.controls objects.

    I wanna vector3 values from polarAngle, aziumthalAngle, and distance between orbitCamera’s position and targetPoint’s position to use control.tween method. Also I am not sure whether I exactly calculated the distance though.

    #Get Distance
    const dx = camera.position.x – targetPoint.x;
    const dy = camera.position.y – targetPoint.y;
    const dz = camera.position.z – targetPoint.z;
    const distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2));

    So my point is how can i convert polarAngle, aziumthalAngle, and distance to vector3. It would be very helpful if you let me know how to do that.

    Many thanks.

    Yuri KovelenovYuri Kovelenov


    why do you need vector3 values for tweening? you can tween scalar values as well.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博



    As you can see the screenshot i attached, in the document it shows that i need to get vector3 value for tweening.

    Unfortunately, I’m not familiar with the scalar value.😢

    {x: number, y: number, z: number} <- Is that scalar value?

    For your understanding, I write down what i want to do with the position variable’s value.

    <input id=”polarAngle”>
    <input id=”aziumthalAngle”>
    <input id=”distance”>
    <button onclick=”tweenViewClick”>Tween Viewer<button>

    function tweenViewClick() {
    const polar = document.getElementById(‘polarAngle’);
    const aziumthalAngle = document.getElementById(‘aziumthalAngle’);
    const distance = document.getElementById(‘distance’);

    // … some logic … how to..

    const postion = {x:.. , y:.., z:.. } // Calculated polarAngle, aziumthalAngle, distance.

    app.controls.tween(postion, targetPosition);

    I want to know x, y, and z value by calculating polarAngle, aziumthalAngle, and distance…😢

    You must be logged in to view attached files.

    I just used below it works ok.
    tweenCamera([30, 30, 10], [0, 0, 0], 10, function() {}, 1);



    You might find this method useful: Vector3.setFromSphericalCoords(radius, phi, theta), where phi is the polar angle and theta is aziumthal.

    Co-founder and lead developer at Soft8Soft.


    Thank to you i figured it out!

    const vector3 = new v3d.Vector3();
    const position = vector3.setFromSphericalCoords(

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.