dcsimg
www.webdeveloper.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 43

Thread: sending global vars to a worker?

  1. #16
    Join Date
    Jul 2013
    Posts
    46
    did you even read the post?
    if you did please let me know at what part i messed up my question lol
    on the first line i was saying that it dose not seem to be possible and if there was any way around it
    then i said the things that where not working AKA THE VAR TAKING TOO LONG TO COPY BECAUSE IT WAS TOO BIG
    then i gave an example of a "work around" that was not quite right but was like i was looking for

    the program and exactly what data i send is useless irreverent to the question and bring it up would make people try to sagest ways to "fix" something that has nothing to do with anything (like what you where doing)
    i mean clearly i should of just left out the inf loop part but i assumed it might be important and it also implied i was using all sorts of var types

    any way i did not think i would get any help here any way lol
    most people just ask noob questions and dont even think a 3d game engine is possible using nothing but everyday js in notepad lol

  2. #17
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,510
    What part of circular referencing is evading you?

    If you check in your console.log (F12 open and close) you should see an error saying something like...
    Code:
    ReferenceError: scene is not defined
    and it won't be because the circular reference to the variable is to a variable that has yet to be initialized and that doesn't happen until the closing '}' has been encountered.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #18
    Join Date
    Jul 2013
    Posts
    46
    did you miss the "(THIS IS JUST A SIMPLE EXAMPLE)" and where i linked the actual project?
    and the "circular referencing" is still not the problem and was just an example of something i was trying to get around >.>

  4. #19
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,510
    Well there you go, the question is answered.

    If this is not the code, you really need to post the code elements that you are having a problem with, but if your actual code is doing what your example is attempting, then the answer is still no.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  5. #20
    Join Date
    Jul 2013
    Posts
    46

  6. #21
    Join Date
    Oct 2013
    Location
    Sheboygan, Wisconsin
    Posts
    1,239
    If it is https://www.twitch.tv/5thfunction

    I opened the site, hit F12 and console shows a bunch of errors.
    Network tab showed loading time of 363 seconds when I gave up. Just a tad beyond the 3 second mark that you want.

  7. #22
    Join Date
    Jul 2013
    Posts
    46
    ya cos i made twitch and "here is where i stream now" what what people normal say when linking a hand made game engine >.>
    i literally re linked it in my last comment directly to the code its self

    for real tho are people just troling or is what i type that confusing ? where did i go wrong on this post (other than expecting randoms to help -_-)

  8. #23
    Join Date
    Jul 2013
    Posts
    46
    and because i know the next comment will be saying what exact part of the code i need help with.... none... all of that code is working fine and it has nothing to do with anything but people seem to think it dose
    i just need to know how to get more than 1 worker to read the same vars at the same time with out deep copying the info to each cos it takes to long because the vars are too big and no i can not make them smaller and what sort of vars thy are is ALL TYPES and what i need them for IS EVERYTHING I CAN POSSIBLY THINK OF and my os is win 7 and i live in a house and the 4th slat from the bottom on my window blinds is broken 2/3 of the way from the left

    let me know if i left out any other bits of impotent irreverent info

  9. #24
    Join Date
    Oct 2013
    Location
    Sheboygan, Wisconsin
    Posts
    1,239
    all of that code is working fine
    That statement changes everything.

    how to get more than 1 worker to read the same vars at the same time with out deep copying the info to each cos it takes to long because the vars are too big
    Are you talking about someone working on the code or a player?

  10. #25
    Join Date
    Jul 2013
    Posts
    46
    a web workers is basically what js calls multi thread support.. with a "worker" being an independent chunk of code code running on a different thread i assume
    it allows you to also use 100% of the cpu power where normally what you use is a single (nurfed by the browser) thread
    so in my case it will make my game engine about 30x on my pc and should make it the quality i want on a phone running on cpu only (i know i can use the gpu but thats not the point of what i am coding)

  11. #26
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,510
    Still does not get around the fact that you are trying to force circular referencing oof an object within itself which is not a legal way of assigning a property in an object a value.... and FYI, no one is trolling you, you are asking for help uet not providing any real world code your having an issue with, simply put, out of politeness, you should post here the code, not a link to a website or online tool like codepen, et al, people have much more time to spend trawling around the internet reading entire website code for you...

    You help people help you by giving them what they ask for and answering their queries.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  12. #27
    Join Date
    Jul 2013
    Posts
    46
    please stop replying when you clearly dont know anything useful and cant help

  13. #28
    Join Date
    Jul 2013
    Posts
    46
    well every work around i try to do for this just means it will take more time to prep the data for use than it would save and the more workers you use the longer it takes XD
    at most i think i would only gain about 4 fps and there is only a VERY few functions i can even run on it

    there must be some way to get it to simply view global vars with out needing to do a deep copy

  14. #29
    Join Date
    May 2016
    Location
    Southern California
    Posts
    80
    I found this online which states to json parse then stringify the object to correctly copy an object in pure javascript, or perhaps you can use jQuery.clone, here is the link:
    http://www.mavenspun.com/javascript/...-structure.htm

    Example from link:
    Code:
    var data_copy = JSON.parse(JSON.stringify( original_data ));

    If that's not it, have you looked into JS CacheStorage or Local Storage?

  15. #30
    Join Date
    Jul 2013
    Posts
    46
    OMG CacheStorage... i think this might be it tho i am too tired to read right now lol
    i was thinking there must be some way to simply store it in a non "DOM" or what ever its called place but i could not put it in to words that google could use lol

    stringify or clone would both make a deep copy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles