我能够渲染.obj模型,但是无法使用Expo-three.js和React Native渲染.fbx模型。

时间:2019-08-24 06:57:35

标签: react-native three.js 3d frontend expo

I am able load and display Expo-three .obj model with React Native , but unable to load .fbx model with the same. In 

呈现.fbx文件时出现以下错误--- 可能的未处理的承诺拒绝(id:0):

> Object {   "bubbles": false,   "cancelable": false,   "currentTarget":
> XMLHttpRequest {
>     "DONE": 4,
>     "HEADERS_RECEIVED": 2,
>     "LOADING": 3,
>     "OPENED": 1,
>     "UNSENT": 0,
>     "_aborted": false,
>     "_cachedResponse": undefined,
>     "_hasError": true,
>     "_headers": Object {},
>     "_incrementalEvents": true,
>     "_lowerCaseResponseHeaders": Object {},
>     "_method": "GET",
>     "_requestId": null,
>     "_response": "",
>     "_responseType": "arraybuffer",
>     "_sent": true,
>     "_subscriptions": Array [],
>     "_timedOut": false,
>     "_trackingName": "unknown",
>     "_url": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FProject-0245bb91-e3e2-42e8-b842-258fd9bfc6c7/ExponentAsset-3ec737573b2ab82919022a7a147b8266.fbx",
>     "readyState": 4,
>     "responseHeaders": undefined,
>     "status": 0,
>     "timeout": 0,
>     "upload": XMLHttpRequestEventTarget {
>       Symbol(listeners): Object {},
>     },
>     "withCredentials": true,
>     Symbol(listeners): Object {
>       "abort": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "error": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "load": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "progress": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>     },   },   "eventPhase": 2,   "isTrusted": false,   "target": XMLHttpRequest {
>     "DONE": 4,
>     "HEADERS_RECEIVED": 2,
>     "LOADING": 3,
>     "OPENED": 1,
>     "UNSENT": 0,
>     "_aborted": false,
>     "_cachedResponse": undefined,
>     "_hasError": true,
>     "_headers": Object {},
>     "_incrementalEvents": true,
>     "_lowerCaseResponseHeaders": Object {},
>     "_method": "GET",
>     "_requestId": null,
>     "_response": "",
>     "_responseType": "arraybuffer",
>     "_sent": true,
>     "_subscriptions": Array [],
>     "_timedOut": false,
>     "_trackingName": "unknown",
>     "_url": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FProject-0245bb91-e3e2-42e8-b842-258fd9bfc6c7/ExponentAsset-3ec737573b2ab82919022a7a147b8266.fbx",
>     "readyState": 4,
>     "responseHeaders": undefined,
>     "status": 0,
>     "timeout": 0,
>     "upload": XMLHttpRequestEventTarget {
>       Symbol(listeners): Object {},
>     },
>     "withCredentials": true,
>     Symbol(listeners): Object {
>       "abort": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "error": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "load": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>       "progress": Object {
>         "kind": 2,
>         "listener": [Function anonymous],
>         "next": null,
>       },
>     },   },   "timeStamp": 1566630132196,   "type": "error",   Symbol(stop_immediate_propagation_flag): false,  
> Symbol(canceled_flag): false,   Symbol(original_event): Object {
>     "type": "error",   },

}

我还要在metro.config.js中添加以下代码,因此使用此代码我仅查看.obj文件。

Here is metro.config.js --

module.exports = {
    resolver: {
    assetExts: ["db", "mp3", "ttf", "obj", "png", "jpg", "otf", "mtl", "fbx"]
    }
    };


Here is app.json --

我也在app.json中添加以下代码,因此使用该代码我仅查看.obj文件。

"packagerOpts": {
      "assetExts": [
        "dae",
        "fbx",
        "obj",
        "mtl",
        "png",
        "jpg"
      ]
    },

这是我在代码中使用的装载机-     可以使用.obj

查看
    this.carobject = await ExpoTHREE.loadAsync([
      require('./assets/model.obj'),
      require('./assets/model.mtl'),
    ],
    null,
    );
    this.scene.add(this.carobject);
  };


unable to view using .fbx

    this.carobject = await ExpoTHREE.loadAsync([
      require('./assets/model.fbx'),
    ],
    null,
    );
    this.scene.add(this.carobject);
  };

I want to Render .fbx file in React Native using Expo-Three

0 个答案:

没有答案