相关疑难解决方法(0)

Three.js - 对象跟随鼠标位置

我正在创建一个球体,Three.js每当它移动时必须跟随鼠标,如本例所示.处理鼠标移动的功能如下:

function onMouseMove(event) {

    // Update the mouse variable
    event.preventDefault();
    mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
    mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;

    // Make the sphere follow the mouse
    mouseMesh.position.set(event.clientX, event.clientY, 0);
};
Run Code Online (Sandbox Code Playgroud)

我附上一个JSFiddle,其中包含完整的代码,根据DOM,你可以看到它mouseMesh是未定义的.你知道我做错了什么吗?

提前感谢您的回复!

javascript three.js

6
推荐指数
1
解决办法
1万
查看次数

地球的多边形三角剖分

填充所有多边形是真的吗?代码笔。据我ThreeGeoJSON所知,它无法填充多边形,只能填充轮廓。我也试过使用Earcut进行三角测量。

drawThreeGeo(data, radius, 'sphere', {color: 'yellow' // I want to edit fill color of lands, not outline color})

html javascript css three.js

4
推荐指数
1
解决办法
1142
查看次数

标签 统计

javascript ×2

three.js ×2

css ×1

html ×1