VR view for the web : error unable to load texture - google-vr

I try to use vr view for the web in localhost. https://developers.google.com/vr/develop/web/vrview-web
My code is :
<script>
window.addEventListener('load', onVrViewLoad)
function onVrViewLoad(){
var view = new VRView.Player('#vrview', { image : 'img.jpg', is_stereo: false, width: 857, height: 297});
}
</script>
<div id='vrview'></div>
My error is :
Render: unable to load texture from "file: ... img.jpg"
I already read every posts on this problem.
I try to use the cardboard camera converter but I have already an equirectangular-panoramic image and it says :
"Conversion error: no valid right eye image found in the XMP metadata.
This might not be a valid Cardboard Camera image."
I don't know why it doesn't work.
Can you help me ?
PS : sorry for my english...

Related

Open Fancybox3 from an iFrame in parent page

I'm sorry but I don't understand Janis's answer on this page
Open fancybox 3 into iframe parent , this is too technical for me as it doesn't give a precise answer.
I can't work out what should be the script needed to open in a parent page from that answer that is pointing to the documentation (which is found in a section about opening iframes, instead of opening FROM an iframe into a parent page) and unfortunately I can't comment on that page so here I am.
How to access and control fancybox in parent window from inside an iframe:
// Close current fancybox instance
parent.jQuery.fancybox.getInstance().close();
// Adjust iframe height according to the contents
parent.jQuery.fancybox.getInstance().update();
OK so that closes or updates the parent window, but how to open various links in the parent window ?
Then Janis says:
This should give you a clue that you can use parent.jQuery.fancybox to use API from the parent page.
But how to "phrase" it ? in a script ?
Then, API section should give you a clue how to open image gallery programmatically:
$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});
Does that mean you have to make a list of all the images you want to open in the parent page in one script ?
If so that doesn't make sense when you have many images and defeats the purpose of making each link call fancybox individually like so :
<a href="images1.jpg" data-fancybox data-caption="image 1">
<img src="images/image1_sm.jpg" alt="" class="image"/></a>
Or does it mean you have to make a script for each picture you want to be opened in the parent page ?
Here is a snippet that would open image gallery in current page or in parent page:
var $fb_links = $('[data-fancybox="images"]');
$fb_links.click(function() {
if ( window.self !== window.top ) {
window.parent.jQuery.fancybox.open( $fb_links, {
//animationEffect : 'fade',
hash : false
}, $fb_links.index( this ) );
} else {
$.fancybox.open( $fb_links, {}, $fb_links.index( this ) );
}
return false;
});
I hope you can see that it is not so scary to create your own click event that starts the script.

Ionic 2 - InAppBrowser Insert CSS by File not Working

Good afternoon,
I'm making an InAppBrowser in my app and i want to add CSS to it by a file in the project. So, I made this code:
let browser = new InAppBrowser('http://usefashion.com/', '_blank', 'location=no, zoom=no');
browser.on('loadstart').subscribe((e)=>{
console.log('Carregando nova página.');
SpinnerDialog.show('Carregando');
});
browser.on('loadstop').subscribe((e)=>{
console.log('Página carregada.');
SpinnerDialog.hide();
browser.insertCss({
file: 'assets/portalstyles.css'
}).then((e)=>{ console.log('CSS adicionado.'); }).catch((e)=>{ console.log('Erro ao adicionar CSS. '+e); });
});
Although, the file are't added to page and in console I'm getting this message:
TypeError: Cannot read property 'apply' of undefined
Can somebody help me?
Thks, Lucas.

Solution for SAPUI5 error message because of templateShareable:true?

Since an upgrade of SAPUI5 1.28.20 I receive the following error message:
A shared template must be marked with templateShareable:true in the
binding info
Code is in MangedObject.js and looks like this:
} else if ( oBindingInfo.templateShareable === MAYBE_SHAREABLE_OR_NOT ) {
// a 'clone' operation implies sharing the template (if templateShareable is not set to false)
oBindingInfo.templateShareable = oCloneBindingInfo.templateShareable = true;
jQuery.sap.log.error("A shared template must be marked with templateShareable:true in the binding info");
}
Value of oBindingInfo.templateShareable is true, value of MAYBE_SHAREABLE_OR_NOT is 1.
According to documentation the default of oBindingInfo.templateShareable is true.
So what is wrong here? A bug in the library? Or something with my code?
See also: https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.base.ManagedObject.html
Update for SAPUI5 version 1.32.x
With version 1.32.x the message has changed it is now:
A template was reused in a binding, but was already marked as
candidate for destroy. You better should declare such a usage with
templateShareable:true in the binding configuration. -
but according to the documentation the default should still be true:
{boolean} oBindingInfo.templateShareable?, Default: true option to
enable that the template will be shared which means that it won't be
destroyed or cloned automatically
Now it looks like, that this produces some endless loading, I got this message again and again till the browser crashes.
Anyone an idea what could be wrong?
Looks like the message occurs if the template was instantiated outside the binding. Example:
This code will work:
new sap.m.Select({
items : {
path : "/Items",
template : new sap.ui.core.Item({
text : "{Name}"
})
}
})
This code seems to produce the message:
var oTemplate = new sap.ui.core.Item({
text : "{Name}"
})
new sap.m.Select({
items : {
path : "/Items",
template :oTemplate
}
})
This seems to fix the problem:
var oTemplate = new sap.ui.core.Item({
text : "{Name}"
})
new sap.m.Select({
items : {
path : "/Items",
template :oTemplate,
templateShareable : true
}
})
The answer above marked as being correct is actually not correct at all because this here is wrong:
Looks like the message occurs if the template was instantiated outside
the binding. [...] This code seems to produce the message: [...]
To prove the answer above os wrong on your own just run this example (SAPUI5 1.28.20 has the same result):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SAPUI5 single file template | nabisoft</title>
<script
src="https://openui5.hana.ondemand.com/1.36.12/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"></script>
<!-- use "sync" or change the code below if you have issues -->
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
var oModel = new sap.ui.model.json.JSONModel({
Items: [
{Name: "Michael"},
{Name: "John"},
{Name: "Frank"},
{Name: "Jane"}
]
});
sap.ui.getCore().setModel(oModel);
var oTemplate = new sap.ui.core.Item({
text : "{Name}"
});
new sap.m.Select({
items : {
path : "/Items",
template : oTemplate
}
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody">
<div id="content"></div>
</body>
</html>
Basically, a clear definition of the lifecycle for templates is (or was) missing in UI5. When this issue was detected there were already many older apps around... So now this new "feature" was introduced somewhen last year (which is kind of backwards compatible). UI5 tries to detect automatically the developer's intention about the lifecycle of a given template used in the binding (using some heuristic). If UI5 cannot clearly tell what the developer actually wanted then you will see this error log - which actually does not affect the functionality at all. It just tells the developer that there is a template somewhere which will not be destroyed by the UI5 runtime. In other words, if you set templateShareable=true then you should make sure to destroy the template in order to avoid memory leaks. So just setting templateShareable=true is not the whole story...
I have published a detailed blog about this: Understanding templateShareable in SAPUI5

jsdom does not fetch scripts on local file system

This is how i construct it:
var fs = require("fs");
var jsdom = require("jsdom");
var htmlSource = fs.readFileSync("./test.html", "utf8");
var doc = jsdom.jsdom(htmlSource, {
features: {
FetchExternalResources : ['script'],
ProcessExternalResources : ['script'],
MutationEvents : '2.0'
},
parsingMode: "auto",
created: function (error, window) {
console.log(window.b); // always undefined
}
});
jsdom.jQueryify(doc.defaultView, 'https://code.jquery.com/jquery-2.1.3.min.js', function() {
console.log( doc.defaultView.b ); // undefined with local jquery in html
});
the html:
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<script src="./js/lib/vendor/jquery.js"></script>
<!-- <script src="http://code.jquery.com/jquery.js"></script> -->
<script type="text/javascript">
var a = $("body"); // script crashes here
var b = "b";
</script>
</body>
</html>
As soon as i replace the jquery path in the html with a http source it works. The local path is perfectly relative to the working dir of the shell / actual node script. To be honest i don't even know why i need jQueryify, but without it the window never has jQuery and even with it, it still needs the http source inside the html document.
You're not telling jsdom where the base of your website lies. It has no idea how to resolve the (relative) path you give it (and tries to resolve from the default about:blank, which just doesn't work). This also the reason why it works with an absolute (http) URL, it doesn't need to know where to resolve from since it's absolute.
You'll need to provide the url option in your initialization to give it the base url (which should look like file:///path/to/your/file).
jQuerify just inserts a script tag with the path you give it - when you get the reference in the html working, you don't need it.
I found out. I'll mark Sebmasters answer as accepted because it solved one of two problems. The other cause was that I didn't properly wait for the load event, thus the code beyond the external scripts wasn't parsed yet.
What i needed to do was after the jsdom() call add a load listener to doc.defaultView.
The reason it worked when using jQuerify was simply because it created enough of a timeout for the embedded script to load.
I had the same issue when full relative path of the jquery library to the jQueryify function. and I solved this problem by providing the full path instead.
const jsdom = require('node-jsdom')
const jqueryPath = __dirname + '/node_modules/jquery/dist/jquery.js'
window = jsdom.jsdom().parentWindow
jsdom.jQueryify(window, jqueryPath, function() {
window.$('body').append('<div class="testing">Hello World, It works')
console.log(window.$('.testing').text())
})

Uploadify OnAllComplete with alert crashes FF4

I have implemented on my page the Uploadify plugin and I am having some trouble with the onAllComplete event with Firefox 4.
I have it implemented like this:
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : 'js/uploadify.swf',
'script' : 'UploadVarios.ashx',
'cancelImg' : 'js/cancel.png',
'folder' : '/uploads',
'multi' : true,
'auto' : true,
'buttonText' : 'Escolher ficheiros',
'removeCompleted' : false,
'fileExt' : '*.doc;*.docx;',
'fileDesc' : 'Ficheiros Word',
onError : function (event,ID,fileObj,errorObj) {
document.forms["form1"].elements["nroErros"].value = 1
}
,
onAllComplete : function(event,data) {
if(document.forms["form1"].elements["nroErros"].value > 0) {
alert('ERROR!');
document.forms["form1"].elements["nroErros"].value = 0;
}
}
});
});
The idea is that if any of the files to be uploaded reports an error, at the end of the upload task an alert message appears.
This works well on IE and on Chrome, but on FF4 after showing the alert and when i try to click on the OK, FF crashes completely.
Any idea on what's going on here?
AS far as I can tell this is a problem related to the alert of Javascript and Firefox 4 and not related to Uploadify itself.
I ended up removing the alert, adding a div on my page and modifying the div content on error.
Not the prettiest job but it works at least on all 3 major browsers.
I had the same problem with Firefox 5 and Uploadify. If you have Firebug installed and if you're just using the alert for debugging during development, you could replace alert('ERROR!'); with console.log('ERROR!');

Resources