我试图在react-native中挂接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.js:55729的这一部分相关。
Object.assign( THREE.MTLLoader.prototype, THREE.EventDispatcher.prototype, {有什么办法可以解决这个问题吗?我是否需要修改aframe来使用不同的赋值,或者有什么方法可以克服这个问题?
我正在运行一个非常简单的hello world,它只是试图加载依赖项而失败。在其他相关问题中,人们表示他们已经通过使用lodash.assign或Object.defineProperties绕过了这个问题--这是一个可行的解决方案吗?在此期间,我可以恢复到react-native的旧版本,但理想情况下,我希望使用带有a-frame的最新版本。
https://github.com/facebook/react-native/issues/5507
https://github.com/facebook/react-native/issues/3634
** UPDATE ** Ok我尝试回滚,安装了react-native 0.36.1,并将我在WebView中加载的站点切换为使用aframe 0.3.2。
我在React原生应用中的代码是这样的:
好的,我尝试回滚,使用rninit安装了原生反应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":"Error:未能对‘WorkerGlobalScope’执行'importScripts‘:未能加载位于http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false’的脚本。\n位于executeApplicationScript (http://localhost:8081/ebuggerWorker.js:207)\n位于onmessage (http://localhost:8081/debuggerWorker.js:38.5)"}
即使我切换到网页视图中加载的非aframe站点,也会出现相同的错误。
发布于 2017-02-15 19:03:16
在反复尝试之后,我发现我的很多问题都是由于试图在模拟器中进行测试造成的。
当在设备上运行时,我能够让一个运行最新版本的a-frame的应用程序与最新版本的react-native一起工作,但只能通过设置react-native来重新编译来自源java的android项目,从当前的master中提取。
我还必须在Android.Manifest中启用硬件加速。
感谢Chris Chen的协助
https://stackoverflow.com/questions/42196398
复制相似问题