【问题标题】:How to load the 3D model (JSON) on current mouse position in Three.JS?如何在 Three.JS 中的当前鼠标位置加载 3D 模型(JSON)?
【发布时间】:2015-01-06 17:07:30
【问题描述】:

我正在尝试实现在当前鼠标坐标上加载 3D 模型的功能。我正在使用 jQuery 拖放功能来加载 3D 模型。我可以将模型加载到画布中,但它不会捕捉到鼠标坐标。

我使用下面的代码将 2D 鼠标坐标转换为 3D 坐标,但它没有提供确切的位置。

function 2DTo3DSpace(event) {
            var planeZ = new THREE.Plane(new THREE.Vector3(1500, 1500, 1500), 0);
            var mv = new THREE.Vector3((event.clientX / window.innerWidth) * 2 - 1, -(event.clientY / window.innerHeight) * 2 + 1, 0.5);
            var raycaster = projector.pickingRay(mv, camera);
            var pos = raycaster.ray.intersectPlane(planeZ);
            return pos;
        }

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

    确保使用相对于画布元素的鼠标位置。

    参见this 线程。

    【讨论】:

      猜你喜欢
      • 2016-06-05
      • 2015-04-20
      • 2017-01-28
      • 2019-05-22
      • 1970-01-01
      • 1970-01-01
      • 2020-06-21
      • 2021-09-25
      • 1970-01-01
      相关资源
      最近更新 更多