Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom renderers #75

Open
trusktr opened this issue Feb 2, 2018 · 2 comments
Open

Custom renderers #75

trusktr opened this issue Feb 2, 2018 · 2 comments

Comments

@trusktr
Copy link

trusktr commented Feb 2, 2018

// TODO: I have mixed feelings about this class. It doesn't actually provide
// anything useful. I assume each game will write their own renderer even in THREE.
// we can make it store a list of objects, and provide a Raycaster, and send events.
// But it hijacks the creation of the scene and the THREE.renderer. It doesn't make
// sense to me that the camera and lights are in the derived class, but the scene and
// renderer are in the base class. seems like inheritance-abuse.
class ThreeRenderer extends Renderer {

I saw your comment there.

I have my own tool that I use for rendering: https://infamous.io

But I suppose that I need to somehow hook it up with Lance in order to take advantage of the client-side prediction of player position, to mitigate network lag, etc. (if I understand correctly, this is what Lance does)

What are requirements for making a renderer? I mean, I see the Renderer source, but some actual guides would be better. Maybe this discussion can be a starting point for that.

@trusktr
Copy link
Author

trusktr commented Feb 2, 2018

Let me also follow the tutorial, that might help...

@OpherV
Copy link
Member

OpherV commented Feb 3, 2018

That's a very good question, and I really appreciate your help in starting a meaningful discussion :)
You have good timing, as I'm actually in the process of refactoring the Pixi renderer for the upcoming Lance v2.

There are two "levels" of renderers - let's call those "Infrastructure renderers" and "game-title renderers".

Infrastructure renderers included renderers like the Pixi.js renderer and the Three.js renderer. They're the connecting glue between Lance (networking) and display (drawing pixels on the screen). They don't actually implement the drawing put themselves, but they're used to hook up Lance to a an actual drawing API and take care the basic needs of multiplayer game rendering. These include things like object creation, object destruction and object updating. Lance itself takes care of "easing" the pain caused by communication latency and syncing (prediction, like you mentioned).

The "game-title renderers" are those implemented by game developers using Lance - they use the APIs provided by Lance to implement their own game title. So any game-specific rendering required for their game will go there.

So requirements for a "renderer" in the Lance case would be to make sure the corresponding display-objects for each game object are created, updated, and destroyed. "Updated" could mean gameplay-specific property updating (like position, which powerup is active) or cosmetic updates (a character's shadow, or idle animation - the arguably that would probably be implemented in the game-title renderer). This gets further complicated by the fact that a game object could consists of sub-render objects. Imagine a tank game object. It's rendering objects and sub-objects could consist of the tank body, wheels, independently rotating turret, smoke particle emitter, and fire particle emitter as it fires.

Does that make sense?

btw infamous.io looks really neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants