[英]How can I display a QRcode on a mesh in three.js?
我从此处http://davidshimjs.github.io/qrcodejs/提取了QRcode库,并希望使用以下代码将其作为纹理显示在网格对象的表面上:
var qrcode = new QRCode( "test", {
text: "http://jindo.dev.naver.com/collie",
width: 128,
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
...
var cuboidTexture = THREE.ImageUtils.loadTexture( qrcode );
cuboidTexture.needsUpdate = true;
但这给了我这个错误:
Uncaught TypeError: Cannot call method 'appendChild' of null qrcode.min.js:1
我做错了什么吗? 还是我无法将QRcode作为纹理?
编辑:使用qrcode.js库的错误是相同的:
Uncaught TypeError: Cannot call method 'appendChild' of null qrcode.js:359
它应该是:
var cuboidTexture = new THREE.Texture( test );
cuboidTexture.needsUpdate = true;
var material = new THREE.MeshBasicMaterial( { map: cuboidTexture } );
第一个参数(“ test”)必须是您想要QR代码进入的DOM元素的ID。
HTML:
<div id="foo"></div>
JS:
var qrcode = new QRCode("foo");
有关其他内容,请参见http://davidshimjs.github.io/qrcodejs/
附言:ID为“ test”的示例没有充分记录;-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.