React / AFrame对象分配错误

时间:2017-02-13 03:48:00

标签: reactjs react-native aframe

我试图在反应原生的内部连接Aframe,但在模拟器中启动时出现此错误:

One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and no spec compliant.

我正在使用Aframe 0.5.0和React-Native 0.41.2

错误是从polyfills.js的第56行引发的,并且与aframe-master.js的这一部分有关:55729。

Object.assign( THREE.MTLLoader.prototype, THREE.EventDispatcher.prototype, {

这有什么办法吗?我是否需要修改aframe以使用不同的作业,或者我是否可以通过某种方式解决这个问题?

我正在运行一个非常简单的hello世界,它只是尝试加载依赖项而失败。在其他相关问题中,人们已经说过他们已经通过使用lodash.assign或Object.defineProperties来解决它 - 这是一个可行的解决方案吗?在此期间,我可以恢复到旧版本的react-native,但我最好使用最新版本的a-frame。

https://github.com/facebook/react-native/issues/5507

https://github.com/facebook/react-native/issues/3634

**更新** 好的我尝试回滚,安装react-native 0.36.1并切换我在WebView中加载的网站使用aframe 0.3.2。

我在React原生应用中的代码是:

好的我尝试回滚,使用rninit安装react-native 0.36.1,并将我在WebView中加载的网站切换为使用aframe 0.3.2。

我在React原生应用中的代码是:

import React, { Component } from 'react';
 // import ReactDOM from 'react-dom';
 import {
   AppRegistry,
   WebView
 } from 'react-native';

 export default class test4 extends Component {
   render() {
     return (
       <WebView source={{uri: 'http://[theurl]/test.html'}}/>
     );
   }
 }


 AppRegistry.registerComponent('test4', () => test4);

aframe应用是这样的:

<!DOCTYPE html>
<html>
    <head>
        <title>A-Frame walkthrough (final)</title>
        <script src="/aframe.js"></script>

    </head>
<body>
  <a-scene>
    <a-assets>
      <img id="circle" src="circle.png"/>
    </a-assets>


      <a-sky src="Ephesus4_1.jpg" rotation="0 -130 0"></a-sky>
    </a-scene>

</html>

当我通过检查chrome:// inspect#devices中的webview打开调试器时,我得到了这个输出:

Mozilla/5.0 (Linux; Android 6.0; Android SDK built for x86_64 Build/MASTER; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Mobile Safari/537.36
aframe.js:54681 Recalculating device params.
aframe.js:54718 User agent: Mozilla/5.0 (Linux; Android 6.0; Android SDK built for x86_64 Build/MASTER; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Mobile Safari/537.36
aframe.js:54719 Pixel width: 2562
aframe.js:54720 Pixel height: 1442
aframe.js:54762 No DPDB device match.
aframe.js:54683 New device parameters:
aframe.js:54684 null
aframe.js:54692 Failed to recalculate device parameters.Dpdb.recalculateDeviceParams_ @ aframe.js:54692
aframe.js:54654 Fetching DPDB...
aframe.js:53106 Using fallback Android device measurements.
aframe.js:56388 Failed to load viewer profile: TypeError: Cannot read property 'getItem' of null
    at Emitter.ViewerSelector (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:56386:36)
    at VRDisplay.CardboardVRDisplay (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:52607:26)
    at WebVRPolyfill.populateDevices (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:56694:17)
    at WebVRPolyfill.getVRDisplays (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:56743:8)
    at new THREE.VRControls (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:66848:13)
    at Object.119.../lib/three (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:66227:16)
    at s (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:1:620)
    at http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:1:671
    at Object.122../bind (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:66358:25)
    at s (http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/aframe.js:1:620)ViewerSelector @ aframe.js:56388
aframe.js:53096 Uncaught TypeError: Cannot read property 'distortionCoefficients' of undefined
aframe.js:54662 Successfully loaded online DPDB.
aframe.js:54681 Recalculating device params.
aframe.js:54718 User agent: Mozilla/5.0 (Linux; Android 6.0; Android SDK built for x86_64 Build/MASTER; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Mobile Safari/537.36
aframe.js:54719 Pixel width: 2562
aframe.js:54720 Pixel height: 1442
aframe.js:54762 No DPDB device match.
aframe.js:54683 New device parameters:
aframe.js:54684 null
aframe.js:54692 Failed to recalculate device parameters.Dpdb.recalculateDeviceParams_ @ aframe.js:54692
http://ec2-52-62-186-186.ap-southeast-2.compute.amazonaws.com:8080/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)

任何建议都将不胜感激!

我也是在Android模拟器中得到这个:

com.facebook.react.common.JavascriptException:{“stack”:“错误:无法在'WorkerGlobalScope'上执行'importScripts':http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false'上的脚本无法加载。\ n \ n在executeApplicationScript上执行http://localhost:8081/ebuggerWorker.js:207)\ n atmessage(http://localhost:8081/debuggerWorker.js:38.5)“}

即使我切换到在webview中加载的非框架网站,我也会收到同样的错误。

1 个答案:

答案 0 :(得分:0)

经过大量的讨论,我发现很多问题都是由于试图在模拟器中进行测试。

当在设备上运行时,我能够获得运行最新版本的a-frame的应用程序,该应用程序使用最新版本的react-native,但只能通过设置react-native从源java重新编译android项目,拉离当前的主人。

我还必须在Android.Manifest中启用硬件加速。

感谢Chris Chen的协助