I'm playing around with the react-VR framework and can't seem to find anything in the docs about entering vr mode on chrome/cardboard ? Any help or pointers much appreciated.
Here is my part of the code while creating a WebVR tour
<View>
<Pano source={asset(this.state.current_scene['scene_image'])} onInput={this.onPanoInput.bind(this)}
onLoad={this.sceneOnLoad} onLoadEnd={this.sceneOnLoadEnd}
style={{ transform: [{translate: [0, 0, 0]}] }}/>
{this.state.current_scene['navigations'].map(function(item,i){
return <Mesh key={i}
style={{
layoutOrigin: [0.5, 0.5],
transform: [{translate: item['translate']},
{rotateX: item['rotation'][0]},
{rotateY: item['rotation'][1]},
{rotateZ: item['rotation'][2]}]
}}
onInput={ e => that.onNavigationClick(item,e)}>
<VrButton
style={{ width: 0.15,
height:0.15,
borderRadius: 50,
justifyContent: 'center',
alignItems: 'center',
borderStyle: 'solid',
borderColor: '#FFFFFF80',
borderWidth: 0.01
}}>
<VrButton
style={{ width: that.state.animationWidth,
height:that.state.animationWidth,
borderRadius: that.state.animationRadius,
backgroundColor: '#FFFFFFD9'
}}>
</VrButton>
</VrButton>
</Mesh>
})}
</View>
onNavigationClick(item,e){
if(e.nativeEvent.inputEvent.eventType === "mousedown" && e.nativeEvent.inputEvent.button === 0){
var new_scene = this.state.scenes.find(i => i['step'] === item.step);
this.setState({current_scene: new_scene});
postMessage({ type: "sceneChanged"})
}
}
sceneOnLoad(){
postMessage({ type: "sceneLoadStart"})
}
sceneOnLoadEnd(){
postMessage({ type: "sceneLoadEnd"})
}
this.sceneOnLoad = this.sceneOnLoad.bind(this);
this.sceneOnLoadEnd = this.sceneOnLoadEnd.bind(this);
this.onNavigationClick = this.onNavigationClick.bind(this);
Maybe you will find something helpful for you also here
for desktop Chrome there is flag: chrome://flags/#enable-webvr
after you enable it and restart Chrome the button "View in VR" will appear, but unfortunately I didn't see any changes when I click it.
I also have tried it on experimental developers build of Chromium, but there was even more flags that should be enabled.
a lot of stuff about tuning your browser is here:
https://superuser.com/questions/836832/how-can-i-enable-webgl-in-my-browser
chrome://gpu/ is very handy to check your 3D environment and don't forget that in some cases (usually on laptops) you can run your browser on integrated videocard instead of powerful GPU, so resluts could be extremly different.
and finally you can check source code of node_modules/ovrui/dist/ovrui.js function attemptEnterVR() to understand better what should happens when you try to switch to VR mode.
Like Pavel Sokolov said, by default WebVR is not enabled and requires updating in the chrome://flags section. This will enable the Show in VR button. However, the current version of Chrome (57) has issues with WebVR, which may result in a black screen for you. In that case, try out Chrome Canary instead, I've had success using it.
I wrote a guide about getting my Cardboard up and running with React-VR, you can read it here.
Related
I want to limit TextInput to full number and the value must be less than 50. I'm leveraging OnChangeText event to intercept the input value and filter it accordingly. It kind of works but the issue is, it briefly displays the text before erasing it. This is an excerpt of my code -
const [userInputValue, setuserInputValue] = useState('');
let onChangeTextInput = (value) => {
const numericRegex = /^([0-9])+$/
if(numericRegex.test(value) && Number(value) <= 50) {
setuserInputValue(value)
}
}
return (
<TextInput
placeholder='Type full number less than 50'
onChangeText={newValue => onChangeTextInput(newValue)}
value={ userInputValue }
textAlign='center'
keyboardType='numeric'
style={{
width: 250,
marginVertical: 10
}}
/>
When I searched online, I found this issue was reported as bug for react-native 0.54.3 and supposedly fixed in 0.57.1 (Bug Report). I'm on 0.70.5. I'm wondering if there's any work around for this problem.
System - iOS
React-native - 0.70.5
I have this style in react-native
backgroundColor: 'rgba(0, 0, 0, 0.8)',
but It gives me this eslint warning Warning eslint(react-native/no-color-literals)
I tried this styling but it didn't work
{
backgroundColor: BLACK,
opacity: 0.8
}
Please check this link to understand the warning.
When developing UIs, we often find ourselves reusing the same colors in multiple places in the UI. If the colors have to be updated, they likely have to be updated across the board. So it's good practice to store the color definitions in variables instead of hardcoding them inside styles. This rule will detect color properties that have literals (ie strings) as values.
You can either disable this warning on eslint or put the string into a variable.
const blackOpa80 = 'rgba(0, 0, 0, 0.8)'
And then:
backgroundColor: blackOpa80,
I am using Platform.OS to check ios and android. It is working fine, But suddenly it returns me 0 instead of 'ios' or 'android'. After some RND I found that when the app is loading the first time, it returns me 'android' but when I switch the screen and check Platform.OS then it returns me 0 value. I am wondered why it is happening.
I am sharing the console result.
when the app is reloading the first time.
LOG Platform.OS
LOG android
after that navigate to the other screen and then check Platform OS.
LOG Platform.OS
LOG 0
I am sharing the code snippet to check Platform
import { Platform } from 'react-native';
componentDidMount() {
console.log('Platform.OS');
console.log(Platform.OS);
}
It looks like you used Platform.OS "=" instead of "==" someplace within the code.
Example :
wrong way:
(Platform.OS ='android')?console.log("this the wrong way):console.log('Oops')
right way
(Platform.OS=='android')?console.log("Youpi it works):console.log('in your dream, this gonna happen again')
Same thing happened with me.
I noted that in one place I have check platform condition using single equal operator by mistake like
paddingTop: (Platform.OS = 'android'
? 16
: 4)
and then after whenever I have checked platform, I always getting 16.
So make sure if anywhere you have check condition, like Platform.OS = 'android' replace it with Platform.OS == 'android'
As #Rajesh Nasit exposed, I had a similar problem, when I wrote
console.log("Platform.OS:" + Platform.OS)
I allways was getting in the console "Platform.OS: 100%"
And the followed error (in Expo CLient App) => 'Unhandled promised error :Invalid platform was passed "100%" '.
Then after reversed my code and checking all the changes I've made, I found the line what was the responsible for thar error.
I had in my StyleSheet the following line
width: Platform.OS === 'android' ? "100%" : "100%",
I asume React-Native somehow set the value "100%" to the Platform.OS.
At final, I resolved that error as follow:
const styles = StyleSheet.create({
imagebackground: {
...Platform.select({
ios: {
width: "100%",
},
android: {
width: "100%",
},
default: {
width: "100%",
}
}),
marginLeft: 0,
},
Well I hope someone find this answer usefull.
I cannot seem to get the colorFilter prop working with my .json file.
There are no errors but the colours are clearly not changing.
<LottieView
style={{
width: 90,
height: 90,
}}
colorFilters={
[
{
keypath: "asdf",
color: "#abcdef",
}
]
}
source={badge.icon}
loop={false}
/>
I'm importing the .json from After Effects using BodyMovin
but am I changing the layer name correctly? If not why on earth is this not working?
I can't get colorFilters to work but you can try doing the following:
import myAnimation from "./../img/myAnimation.json";
in the render part use LottieView with the import and not with the require inline
<LottieView
//source={require("./../img/radius.json")}
source={myAnimation}
/>
Now you can manipulate the properties directly from the json object, just for example here I manipulate the color based on the actual color (from black to white or from white to black)
myAnimation.layers[1].shapes[0].it[1].c.k = myAnimation.layers[1].shapes[0].it[1].c.k[0] == 0 ? [1,1,1,1] : [0,0,0,1];
To find out what is the property you need, check the json, it is not very clear but with some trial and error you can understand the structure.
Just try with react native, and it's work fine for me
<LottieView
style={style.heartLootie}
source={require("../../assets/animations/favorite_animation.json")}
progress={animationProgress}
colorFilters={[
{ keypath: "Red Heart", color: themeColors.PRIMARY },
{ keypath: "Grey Heart", color: themeColors.SECONDARY },
]}
/>
This is an outstanding issue, I have opened an issue here and will work with the devs to hopefully resolve this issue. It is probably the biggest bottleneck for React Native adoption right now.
I open a second window like that... its possible change the user-agent or other values for this window??
var new_win = gui.Window.open('http://google.com', {
position: 'center',
width: 300,
height: 300
//,show: false
});
I need change randomly this params(headers) for that my application works fine.
im using:
node-webkit v0.11.4
node.js v0.11.13-pre
Chromium 38.0.2125.104
commit hash: fa7a807-d8ecacd-e98a5c7-f2f89e2-d9a9d39-cdd879e
I don't find any solution to change the user-agent in Window.open.
But you can use iframe#nwUserAgent to change it .
For example:
index.html
var new_win = gui.Window.open('iframe.html', {
position: 'center',
width: 300,
height: 300
//,show: false
});
iframe.html
<iframe src="http://google.com" nwUserAgent="test" style="width:100%;height:100%"></iframe>