Threejs第2行无法进行Json()序列化

rfbsl7qr  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(70)

我在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的一个错误/缺失的特性?
谢谢你,谢谢

uidvcgyl

uidvcgyl1#

这是LineGeometry的问题,这个几何体没有一个toJSON()方法来序列化它自己,我猜这是一个bug。

相关问题