我在Threejs(v 146)中添加了一行2
const lineGeometry = new LineGeometry();
const line2Points = [10, 10, 0, 0, 10, 0, 0, 0, 0, 10, 0, 0];
lineGeometry.setPositions(line2Points);
const matLine = new LineMaterial({
color: 0xe3e1e1,
worldUnits: true,
linewidth: 0.3,
dashed: false,
alphaToCoverage: false,
transparent: false,
opacity: 1,
depthWrite: false,
depthTest: false,
});
const line = new Line2(lineGeometry, matLine);
line.toJSON();
字符串
调用line.toJSON();
会弹出以下错误:
Uncaught TypeError: Cannot convert undefined or null to object
at extractFromCache (three.module.js:8296:5)
at Line2.toJSON (three.module.js:8263:23)
型
在官方示例https://threejs.org/examples/?q=line#webgl_lines_fat中,也可以通过在第123行添加line.toJSON();
调用来轻松复制它
你知道序列化是如何实现的吗?或者这是Line 2的一个错误/缺失的特性?
谢谢你,谢谢
1条答案
按热度按时间uidvcgyl1#
这是
LineGeometry
的问题,这个几何体没有一个toJSON()
方法来序列化它自己,我猜这是一个bug。