首页 > 解决方案 > 将笛卡尔坐标缩放到平面

问题描述

我有一组笛卡尔坐标,我试图在平面上显示,但一起显示。

我这样做是为了展示:

//coordinates
var coords = [{x: 38.312994420265, z: -6.73293614518871 },
            { x: 38.3121606727708, z: -6.73414861996415 },
            { x: 38.31209393925, z: -6.73365394789821 },
            { x: 38.309765, z: -6.733786 },
            { x: 38.3098334832724, z: -6.73374153262405 },
            { x: 38.3101738571429, z: -6.73400842857143 },
            { x: 38.3098832732111, z: -673400942857143 },
            { x: 38.31065825, z: -6.73382525 },
            { x: 38.3121424443978, z: -6.73440437325536 },
            { x: 38.312321, z: -6.734591 },
            { x: 38.3135465825497, z: -6.73486983169236 }];

//load scene and set center coordinate
function CargarCamara() {
    scene = new THREE.Scene();
    scene.position.set(38.313,0,-6.735);
    //camera
    camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.set(0, 300, 500);
    camera.lookAt(scene.position);      

    //lights
    light = new THREE.PointLight(0xffffff, 1, 4000);
    light.position.set(50, 0, 0);
    light_two = new THREE.PointLight(0xffffff, 1, 4000);
    light_two.position.set(-100, 800, 800);
    lightAmbient = new THREE.AmbientLight(0x404040);
    scene.add(light, light_two, lightAmbient);
}

//set cardinal points
function Cubo() {
      
    const bola = new THREE.SphereGeometry(5);
    const meta = new THREE.MeshBasicMaterial({ color: 0x0000ff });
    const punto = new THREE.Mesh(bola, meta);

    for (let i = 0; i < (coords.length - 1); i++) {
        let aux = punto.clone();
        aux.position.set((coords[i].x - scene.position.x ), 10, (coords[i].z - scene.position.y ));
        coordenadas.add(aux);
    }   
    scene.add(coordenadas);
}

我也有这个问题。

我怎样才能将该坐标缩放到我的飞机上?

标签: javascriptmaththree.js

解决方案


推荐阅读