Search code examples
javascriptobjectthree.jsrenderingscene

Rendering Speed: more objects or more scenes?


I'm trying to make a game that has three scenes, each with different functions, but they all need the same three.js objects in them.

My question is: in terms of rendering speed, is it better to use three cameras, and just reposition the blocks when I change from one scene to another, or use three scenes which all hold the same types of objects but they are actually different objects and they don't have to be moved?

If you don't understand that, imagine this: I have a scene full of three.js objects shaped like letters, and they spell a paragraph. I want a new paragraph with the same letters, but is it better for the rendering speed to move all the letters around, or flip to a scene that has already been loaded with the same letters, but in the shape of the new paragraph?

I am totally open to alternative ways of accomplishing this task, as long as they are only with JavaScript.

Thank you very much!


Solution

  • I believe you're referencing the wrong problem. Two scenes with 50 objects each will render in (relatively) the same amount of time on the GPU. The "rendering speed" you're considering includes scene processing to reposition your letters. So the real problem you're facing is finding a minimal number of operations in order to position your letters from one scene to the next.

    If we make a few assumptions:

    • You don't care about memory
    • You don't care about the time it takes to initially set up the scenes
    • You don't plan on rearranging the letters further than the given scenes

    Then the fastest you can go is to have separate copies of all the objects. You wouldn't need to perform any repositioning, so you would jump directly to the render step.