I am going to proceed with importing point cloud through potree with the following example file.
https://github.com/Autodesk-Forge/forge-extensions
I was working with the example file, but I got an error "BufferGeometry.addAttribute() is deprecated. Use BufferGeometry.setAttribute() instead". This problem also occurs in the example file driven site. It happens on other computers as well. Here is the error I got:
enter image description here
If this extension works normally, you should see the point cloud converted from the port tree.
Thank you for the heads-up. The Potree library was ported to the viewer couple years ago, when the viewer was still using WebGL. Now the viewer is using WebGL2 which is why the port is causing issues. In order to get it working again, I'd suggest that you disable WebGL2 support in the viewer by passing the following options to viewer.start (the first four params can be ignored):
viewer.start(undefined, undefined, undefined, undefined, {
webglInitParams: {
useWebGL2: false
}
});
After that I was able to load the point cloud again. Here's a branch of one of our code samples with this modification: https://github.com/autodesk-platform-services/aps-simple-viewer-nodejs/tree/sample/potree.
Also, note that the addAttribute vs setAttribute are just deprecation warnings, not errors. In the code branch above I've updated the potree.js script as well so that the warnings do not appear anymore.
I wanted to ask that for security reasons - we should be able to remove the meteor version information from the meteor_runtime_config section from the page source section and other headless browser/curl requests like below:
__meteor_runtime_config__ = {"meteorRelease":"METEOR#1.0.3.1"...
Especially so that known vulnerabilities are not exploited. This gives developers the some what time to catch to the new version especially with breaking changes to the code.
Here from a blog post back in 2014, 31 apps were reported to have removed the version number, so it is possible to do so.
A trick is to empty __meteor_runtime_config__.meteorRelease at the startup phase.
Meteor.startup( function() {
__meteor_runtime_config__.meteorRelease = undefined;
});
You can also remove the string assigned to meteorRelease in <application>/bundle/programs/server/config.json before you deploy your application. The information is extracted from that config file, which is generated by Meteor when it builds applications.
I am using the this within an audio experiment of mine.
audiometa: function(){
channels = audio.mozChannels;
rate = audio.mozSampleRate;
frameBufferLength = audio.mozFrameBufferLength;
fft = new FFT(frameBufferLength / channels, rate);
},
For some reason, mozChannels/mozSampleRate and mozFrameBufferLength is undefined using the latest version of Firefox. Reading the cos, I can't explain myself, why this could happen.
Is there something within the about:config page which I need to turn on? (Have tried it local and on a webserver)
By the way, I am using this example.
https://wiki.mozilla.org/Audio_Data_API#Reading_Audio
Thanks
It looks like Firefox no longer supports mozChannels, mozSampleRate and mozFrameBufferLength. That would cause an undefined error. The link to the doc you provided has a note that says that API has been deprecated in favor of the W3C Web Audio API. And I searched through the Firefox codebase here:
https://dxr.mozilla.org/mozilla-central/source/
And those properties do not appear in the Firefox code. I suggest you try using the W3C Web Audio API:
https://webaudio.github.io/web-audio-api/
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
I am currently working on a calculator that will run as a packaged (desktop) chrome app. I am using the math.js library to parse math input. This is my old code:
evaluate.js:
var parser = math.parser();
function evaluate(input){
$("#output").text(parser.eval(input));
}
However, if the input is something unreasonable like 6234523412368492857483928!, the app just freezes, because it is trying to evaluate the input. I know that math.js is still in beta so eventually there might be a fix (overflow errors), but I couldn't find any other library that parses raw input the way math.js does.
To fix this, I am trying to fix this using web workers to run it asynchronously. Here is the code that I have right now:
main.js
var evaluator = new Worker('evaluate.js');
evaluator.addEventListener('message', function(e){
$("#output").text(e.data);
}, false);
function evaluate(input){
evaluator.postMessage(input);
}
evaluate.js
var parser = math.parser();
function mathEval(input){
return parser.eval(input);
}
self.addEventListener('message', function(e){
self.postMessage(mathEval(e.data));
});
However, this doesn't work when I run it. Also, I noticed that when I use web workers, it throws the error Uncaught ReferenceError: math is not defined - evaluate.js:1, but it didn't throw this error with the old code.
Questions: Why doesn't this code work to evaluate the input? Is it possible to use multiple workers to speed it up? If I wanted to implement some sort of overflow error for when the worker takes more than 2 seconds, what would be the best way to go about doing it? Finally, is there a better way to do this?
Web Workers are run in totally separate context. They don't have access to the objects from parent web page. If you want to use math.js you have to import it into the worker using importScript.
I recommend to read Using Web Workers guide, part "Importing Scripts And Libraries" which describes how to do it, and how it works in detail.
I can't come up with a good explanation for this, but when I include
<script type="text/javascript" src="phonegap.js"></script>
In my Phonegap app, which I have not modified, 2 pops will appear on screen.
//The first popup
gap:["PluginManager","startup","PluginManager224542697"]
//the second
gap:["App","show","App224542698"]
I have to cancel both popups and would really love to understand the reasoning.
The two lines in question are on line 21117 and 21118 of phonegap.js
// Tell the native code that a page change has occurred.
require('cordova/exec')(null, null, 'PluginManager', 'startup', []);
require('cordova/channel').onNativeReady.fire();
This of course does not break when its in the app, but it does mean that development is next to impossible.
For me the issue was occurring because phonegap.js was falling back to PROMPT based mode when running outside of phonegap. I believe this mode is intended for phonegap below Android 3.2, where all communication is via alert prompts (which is what you're seeing).
I fixed the problem by setting the following variable before loading phonegap.js:
window._cordovaNative = true;
This tricks phonegap into thinking you're running above phonegap 3.2 hence never enters Prompt mode.
Of course, if you're targeting devices below 3.2 then doing this will probably break all communication with Phonegap on those devices...
I have stumbled upon this error and question while trying the following:
Completed the hello world tutorial with cordova create, etc.
Deployed both on emulator and the connected device w/o a problem.
I got the same error as OP when doing cordova serve and just navigating to //localhost:8000 as instructed.
I agree - seeing those alerts is super annoying. It kills the whole point of speedy non-native js-based development.
What is going wrong?
Communication API with the "device" is falling back to this handler promptbasednativeapi.js (also see cordova-js/src/android/exec.js). On version 3.x.x just saying
window._cordovaNative = true;
was not enough for me. One should implement the whole protocol of communication.
Quick solution
You can use some browser side "emulator", e.g. Ripple emulator extension for chrome ([UPDATE] Consider using https://github.com/apache/incubator-ripple for phonegap 3.x.x as pointed by DuKes0mE). Such an "emulator" can understand and fire respective events, e.g. "device ready". So far it looks promising :-)
What is going on?
An answer by #antscode was of great help. After some digging and reading of cordova/cordova-js code I figured out that
Error comes from the mechanism which is a part of cordova plugin architecture. Plugins are developed as so called cordova commands which can be executed from js - this is exactly how cordova architecture is organized.
Cordova is a JS framework. One is suggested to primary write (non-native) JS code. To talk to all those different native plugins one has to come up with the protocol to communicate with them, sort of RPC with JSON serialization. This is exactly what is going own.
Plugins can be also in pure JS. To quote the manual
Create a new echome plugin with:
window.echo = function(str, callback) {
cordova.exec(callback, function(err) {
callback('Nothing to echo.');
}, "Echo", "echo", [str]);
};
Access it as a cordova command via JS:
window.echo("echome", function(echoValue) {
alert(echoValue == "echome"); // should alert true.
});
No emulator solution
I could imagine a situation when an rather complicated app will break just inside such an web-browser client side "emulator" (and only in it). A better solution would be to figure out a way to convince the app not to fallback to PROMPT method of communication (the one that makes annoying alerts). Well, I do not have such a solution right now :-( Will be happy to learn how to do it though.
Solution is here: https://gist.github.com/ewiger/7d5e0cc8fccf311e9ce2
there is probably no return event for the cancel button. if no instructions are passed to the kernel, this results in an exception(your browser crashing.) try defining an action for the cancel button and see if that helps.
I went into hello/platforms/ios/CordovaLib and copied the cordova.js file into my www root and changed
Or download from here:https://github.com/apache/cordova-ios/blob/master/CordovaLib/cordova.js
<script type="text/javascript" src="phonegap.js"></script>
to
<script type="text/javascript" src="cordova.js"></script>
and no more popups
I was having the same issue with a project created by another developer. The cause in my case was the remains of the Cordova/PhoneGap 2.x configuration. This popup is related to the plugin system. Removing plugin from my config.xml made it better:
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
The end, I decided it would be best to make a new 3.x project and move all of my HTML/CSS/JS to the newly created project. The new project fixed all issues.
I had initially resisted posting an answer on this question. As was mentioned by one of the developers that the phonegap.js should not be included unless it is production code.
This however means you can't tests phonegap features.
To briefly explain my thought process, in all my years developing (php) I have often set global variables that I can easily write code for dev, stage or production.
Please consider this might not be the best way to go, but for me it works and I'm enjoying the rest of my backbone app far more than revisiting this currently ;)
So, I did this:
//Define SD
var SD = {}; //define SD so we can use it globally
/*==================================================
Is Mobile - If true then we are a mobile
================================================== */
SD.isMobile = true;
//This is with the assumtion that your domain contains (for exmaple) http://yourdomain.local
if (document.URL.indexOf("local") > 0 || document.URL.indexOf("sex") > 0) {
SD.isMobile = false;
}
SD = {
isMobile: SD.isMobile,
ENVIROMENT: 'liveApp',
CDN: 'yoururl.com/',
HTTP: 'http://yoururl.com/',
}
// #define the globals depending on where we are -----------------------------------------------------
SD.globals = function () {
switch (window.location.hostname) {
case "sd.local":
SD.ENVIROMENT = 'localApp',
SD.CDN = 'sd.local/',
SD.HTTP = 'http://yoururl.com/',
SD.AJAX = SD.HTTP+'app/';
break;
case "192.168.0.25": //Set to your machines IP address
SD.ENVIROMENT = 'mobilePhone',
SD.AJAX = SD.HTTP+ 'app/';
break;
default:
SD.AJAX = SD.HTTP+'app/';
break;
}
};
And now finally, after all the init work I add the phonegap.js if we need it.
if(SD.isMobile){
$.getScript('phonegap.js', function( data, textStatus, jqxhr){
c( "cordova was loaded." );
});
I was experiencing the exact same two popups you describe but only experienced them when i added iOS to my phonegap project. the first time i did this i copied the www folder from my working Android app. this was the problem because it had artifacts from the Android plugins. After blasting and recreating the iOS app in the phonegap project using the command line tools i more carefully brought over only the needed html, js and css files for my app which resolved the issue.