rSimulate / Cosmosium

:earth_americas: js game engine for space-based games
Other
23 stars 7 forks source link

Breaking the WebGL Scene into Multiple Components with HTML/CSS Click Conditionals #42

Closed iontom closed 9 years ago

iontom commented 10 years ago

Either deploy this, or something like this.. We just need something where page click conditionals are passed from the HTML/CSS layer into PYTHON, so that Python can spit back out sections/chunks of a webGL scene based on those conditionals. Also, we need to be able to do this without reloading the page... Or if we do force a reload, to keep the same camera state.

The other option is to try and use controls written in JS within the frame, and then try to pass the controls' states back up into Python and vice versa... This is a pretty tough problem.

We might try webGL in the CSS like done in the 100,000 stars application: http://www.emagix.net/academic/mscs-project/item/camera-sync-with-css3-and-webgl-threejs

Something like MontageJS would have sort of worked here... But that's nodeJS based, not python. We are in need of a pretty crazy solution.

Anyway, here's the mock code for scene templating in a simple example with multiple components:

  @route('/examplescene')
  def CreateExamplePage
      return template('tpl/webgl/scene_start.tpl', ......)     // Requirements and scene declaration
      return template('tpl/webgl/scene_space.tpl', ......)   // Creates basic scene framework for          space_view or tech_view, etc

      IF(Player clicks HTML/CSS button) Then
               OOI-Load Asteroid Subset // (Picks whether to show NEO, MB, all or none)
                        IF (click=NEO) then         
                               return template('tpl/webgl/scene_NEO')
                        ELSE IF (click=MB) then         
                               return template('tpl/webgl/scene_MB')
                        ELSE IF (click=NONE) then         
                               return template('tpl/webgl/scene_NONE')
                        ELSE () then         
                               return template('tpl/webgl/scene_BOTH')

 return('tpl/webgl/scene_end.tpl',...)
7yl4r commented 10 years ago

The handling of different datasets through templating is implemented, but we might still need to handle this better... i.e. without reloading the scene. I guess we would do this by writing a reloadAsteroids method in js.

BrianErikson commented 9 years ago

The majority of this was fixed in this merge. What I ended up doing was had all of the HTML templates served at once, and then based on what the user clicks on in each template, will send a query to the server to request the result of it. This cleared us of our webGL context loss issue, and sets us up for all the queries we could ever need. The idea is to use send/websockets to recieve information and then just append to the html divs where needed. I guess we may be able to figure out a way to do that with GET/POST requests with templates, but in my opinion it's a lot easier to do with JSON data structures and the like. Right now there's also zero querying going on (besides pulling in asteroids from the DB the legacy way), so this is something that we still have to work on; I don't really consider this issue to be closed yet.

BrianErikson commented 9 years ago

Issue solved by websocket streaming. Closing issue.