Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在three.js中动态更改精灵文本_Three.js - Fatal编程技术网

在three.js中动态更改精灵文本

在three.js中动态更改精灵文本,three.js,Three.js,我使用sprite在three.js中创建sprite。 它是有效的。但我想改变画布纹理的动态。 也许我可以使用fillText来更改文本。但是它的效果并不好。 我只是想让它看起来像电子表 let canvas = document.createElement('canvas'); canvas.width = w; canvas.height = h; let ctx = canvas.getContext('2d'); drawBg(ctx, bg); drawText(ctx, data)

我使用
sprite
在three.js中创建sprite。 它是有效的。但我想改变画布纹理的动态。 也许我可以使用
fillText
来更改文本。但是它的效果并不好。 我只是想让它看起来像电子表

let canvas = document.createElement('canvas');
canvas.width = w;
canvas.height = h;
let ctx = canvas.getContext('2d');
drawBg(ctx, bg);
drawText(ctx, data);

let texture = new THREE.CanvasTexture(canvas);
texture.needsUpdate = true;
let material = new THREE.SpriteMaterial({map: texture});
let spriteOject = new THREE.Sprite(material);
spriteOject.scale.set(scale * w / h, scale)
spriteOject.position.set(positions[0], positions[1], positions[2]);