'js code with type="module" is doesn't work in my vr environment
I work in a vr environement codding with A-FRAME, I use https://github.com/supermedium/superframe/tree/master/components/log/ to prints logs in vr environement.
<head>
<title>My A-Frame Scene</title>
<script src="https://aframe.io/releases/0.9.0/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-log-component/dist/aframe-log-component.min.js"></script>
<script type="module" src="./f1.js"></script>
<script type="module" src="./f2.js"></script>
</head>
<body>
<a-scene id='main_scene'>
<a-entity log="channel:c1" geometry="primitive: plane" material="color: #111" text="color: lightgreen" position="0 0 -4"></a-entity>
</a-scene>
</body>
And in my js I have this:
//f1.js
import foo from 'f2.js'
function f(ts){
//...
$('#main_scene').append('<a-entity obj'+ts.name+'></a-entity>');
AFRAME.registerComponent(
'obj'+ts.name,
{
init:function(){
var el = this.el;
el.setAttribute("geometry","primitive:box;depth:"+0.01+";height:"+0.06+";width:"+0.04);
el.setAttribute('color',"#027523");
el.setAttribute('position',{x:ts.x,y:ts.y,z:ts.z});
el.setAttribute('rotation',{x:0,y:ts.orientation,z:0});
},
tick: function(){
foo();
},
}
);
//...
}
//f2.js
function foo(){
AFRAME.log("hello",'c1')
}
export default foo
In firefox browsers if i don't use vr It works, but with vr glasses doesn't work. In vr, the object is not created. When I don't use type="module" and I'm codding in a single script, it's works (the problem is not with the logs but with the objects that are not "created")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
