我试图使用two.js在屏幕上使用makeLine()函数绘制一条线。
但是它只是给出了一个错误消息,上面写着TypeError: this.scene is undefined。
有人能帮我解决这个问题吗?提前谢谢。
代码:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>connectDots</title>
<script src="../two.min.js"></script>
</head>
<body>
<div id="drawings"></div>
<script src="script.js"></script>
</body>
</html>script.js
var drawingLocation = document.querySelector("#drawings");
var two = new Two({fullscreen: true}).appendTo(drawingLocation);
var line = new two.makeLine(two.width / 2 - 100, two.height / 2, two.width / 2 + 100, two.height / 2);
line.linewidth = 10;
two.update();发布于 2020-11-18 07:01:22
从这一行中删除new关键字:
var line = two.makeLine(two.width / 2 - 100, two.height / 2, two.width / 2 + 100, two.height / 2);在这里,您尝试在two对象上调用方法two。关键字new将假定您正在调用构造函数来创建对象。这可能是你的问题。
https://stackoverflow.com/questions/64888352
复制相似问题