THREE.js 纹理在 SVGRenderer 中不可见

发布于 2025-01-08 13:52:14 字数 990 浏览 0 评论 0原文

我们尝试了下一个代码:

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.0001, 999);
camera.position.set( 0, 0, 3 );
scene.add( camera );

var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );

var image = $('#tmp')[0]

var texture = new THREE.Texture(image);
texture.needsUpdate = true;
var img_material = new THREE.MeshBasicMaterial({color: 0x000000, map: texture });
var plane_geometry = new THREE.PlaneGeometry(2, 2);

var imageMesh = new THREE.Mesh(plane_geometry, img_material);
imageMesh.doubleSided = true;
scene.add(imageMesh);

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );

$('#container').append( renderer.domElement );
renderer.render(scene, camera);

但是当我们切换到:

renderer = new THREE.SVGRenderer();

它停止在图像几何上渲染纹理。有人能说说为什么会这样吗?

We've tried the next code:

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.0001, 999);
camera.position.set( 0, 0, 3 );
scene.add( camera );

var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );

var image = $('#tmp')[0]

var texture = new THREE.Texture(image);
texture.needsUpdate = true;
var img_material = new THREE.MeshBasicMaterial({color: 0x000000, map: texture });
var plane_geometry = new THREE.PlaneGeometry(2, 2);

var imageMesh = new THREE.Mesh(plane_geometry, img_material);
imageMesh.doubleSided = true;
scene.add(imageMesh);

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );

$('#container').append( renderer.domElement );
renderer.render(scene, camera);

but when we switched to:

renderer = new THREE.SVGRenderer();

it stop rendering texture over image geometry. Can anybody say why so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薔薇婲 2025-01-15 13:52:14

THREE.SVGRenderer 不支持纹理。

THREE.SVGRenderer doesn't support textures.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文