antonioiacobucci / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 0 forks source link

Unable to import poly2tri.js script in web worker script. #35

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create Web worker script.
2. Use importScripts() to import poly2tri.js in onmessage() of worker.
3. In chrome (on F12), you can see the error as "Uncaught ReferenceError: 
window is not defined"

What is the expected output? What do you see instead?
Script should get loaded. But failing to load script.

What version of the product are you using? On what operating system?
Windows 7, Google chrome 16.0.912.63 m

Please provide any additional information below.
Please see the below code for main script and worker script.

//main script file.

//callback function for web worker.
function callback(event) {
    console.log(event.data);
}
var w = new Worker('task.js');
w.onmessage = callback;
w.postMessage("Hi"); // call worker.

//task.js file
self.onmessage = function(event) {
    importScripts('poly2tri.js'); // load the poly2tri utility.
    this.postMessage("Hello");
};

Original issue reported on code.google.com by mahesh4c...@gmail.com on 20 Dec 2011 at 12:39

GoogleCodeExporter commented 8 years ago
I am unable to find use of "window" object in poly2tri.js file :( 
Is there use of "window" object for this utility ?

Original comment by mahesh4c...@gmail.com on 20 Dec 2011 at 12:41

GoogleCodeExporter commented 8 years ago
Sorry the actual error is "Uncaught ReferenceError: Namespace is not defined"

Original comment by mahesh4c...@gmail.com on 20 Dec 2011 at 12:56

GoogleCodeExporter commented 8 years ago
I'm sorry the javascript port was not written by any of the authors of this lib 
but simply ported by a user. So can't really help you since I've never worked 
with javascript myself.

You might try to ask the original javascript porter if he have any insights.
http://code.google.com/p/poly2tri/issues/detail?id=5&can=1

Original comment by thahlen@gmail.com on 20 Dec 2011 at 11:39

GoogleCodeExporter commented 8 years ago

Original comment by thahlen@gmail.com on 5 Jan 2012 at 11:03

GoogleCodeExporter commented 8 years ago
got workaround for this:
remove the use of "Namespace"; instead use like MyNameSpace = MyNameSpace || {};
this solves the issue.

Original comment by mahesh4c...@gmail.com on 6 Jan 2012 at 5:15

GoogleCodeExporter commented 8 years ago
Thanks for posting the solution to your problem :)

Original comment by thahlen@gmail.com on 6 Jan 2012 at 11:08

GoogleCodeExporter commented 8 years ago
see change in issue 68 : Namespace.js dependency is now optional    

Original comment by remi.tur...@gmail.com on 14 Mar 2013 at 8:51