这可能是重复的,但我还没有找到任何东西.我正在尝试为鼠标悬停创建工具提示.(透视相机)
工具提示问题:https: //jsfiddle.net/thehui87/d12fLr0b/14/
threejs r76
function onDocumentMouseMove( event )
{
// update sprite position
// sprite1.position.set( event.clientX, event.clientY, 1 );
// update the mouse variable
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
var vector = new THREE.Vector3( mouse.x, mouse.y, 0 );
vector.unproject(camera);
var dir = vector.sub( camera.position ).normalize();
var distance = - camera.position.z / dir.z;
var pos = camera.position.clone().add( dir.multiplyScalar( distance ) …
Run Code Online (Sandbox Code Playgroud) 我一般对Three.js和WebGL还是陌生的,我正在尝试制作一个简单的3D地球地球,上面应用了SVG纹理(以便可以放大而不会造成质量损失)。
我尝试加载svg图像而不是png图像。我工作了,但是图像“栅格化了”,从而消除了使用svg的所有优点:/
有可能这样做吗?如果是,怎么办?
谢谢
this.loader = new THREE.TextureLoader();
this.loader.load("someimage.svg", texture => {
//create the sphere
const sphere = new THREE.SphereGeometry(RADIUS, SEGMENTS, RINGS);
//map the texture to the material. Read more about materials in three.js docs
const material = new THREE.MeshBasicMaterial({
map: texture,
overdraw: 0.5
});
//create a new mesh with sphere geometry.
const mesh = new THREE.Mesh(sphere, material);
//add mesh to globe group
this.globe.add(mesh);
});
Run Code Online (Sandbox Code Playgroud)