【问题标题】:Using THREE OBJLoader in Gatsby Production Build在 Gatsby 生产环境中使用三个 OBJLoader
【发布时间】:2020-04-20 01:51:38
【问题描述】:

我正在尝试在我的 gatsby 项目中添加一个threejs 场景。

经过一些流血之后,我让它在开发和构建中正常工作,但是在提供应用程序时,我得到了 3 次以下错误:

TypeError: (void 0) is not a constructor

我通过日志发现错误出现在使用 OBJLoader 构造函数时。我怎样才能让它工作?

我基本上是这样设置的:

import React from "react";
import * as THREE from "three";
import * as OBJLoader from "three-obj-loader"

OBJLoader(THREE);

const SceneComponent = (}) => {

   const manager = new THREE.LoadingManager();

   manager.onLoad = () => {
     animate()
   };

  const loader = new THREE.OBJLoader(manager).load(`PATH`, (spoon) => {
    scene.add(spoon)
  }
 ...
}

【问题讨论】:

    标签: reactjs three.js gatsby three20 react-functional-component


    【解决方案1】:

    如果有人感兴趣: 我通过切换到“three-gltf-loader”并将网格转换为“.glb”解决了这个问题,这似乎是最佳实践,因为它也是文件大小的一半。

    【讨论】:

      猜你喜欢
      • 2021-11-10
      • 2022-11-02
      • 1970-01-01
      • 2011-03-02
      • 2013-08-15
      • 2012-01-26
      • 2012-02-04
      • 2019-10-14
      • 1970-01-01
      相关资源
      最近更新 更多