New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

github.com/tomasz-brak/thhar-3d

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tomasz-brak/thhar-3d

  • v0.0.0-20240421091613-9a1092a29b0e
  • Source
  • Go
  • Socket score

Version published
Created

Thhar

Thhar is a 3d rendering engine written in go. Based on ebiten, it allows for rendering complex shapes. It supports Wavefront's .obj format. cube

Live demos

Demos can be found on my blog https://blog-per.vercel.app/demos, check the rendering with thhar section

Usage

Only requirement is to put a .Render function in any ebiten application's main loop. Calling it with our camera instance and passing in details about the color of rendered lines.

func (g *Game) Draw(screen *ebiten.Image) {
	// Camera movement code is included in the library. If you want to use your own code for that you can by modifying the "origin" of the camera.
	renderer.HandleMovement(&Camera)
	// Rendering 3d objects
	renderer.Render(screen, Objects, &Camera, color.White)
}

extract from ./examples/basic/example.go

Handling movement can be done using the .HandleMovement function (this uses default ebiten key press detection, Keybinds), passing by the Camera every frame. If more customization is needed the Camera's angle and position variables are exposed and can be used to adjust or remove completely the ability to move the camera.

Multiple cameras can be used to performed sequenced actions (check examples). Even multiple .Render calls per frame are accepted. Be careful to not render two objects with different cameras in the same frame, or some weird visuals may be seen

Sources

The engine was designed for the Motorola Science Cup 2023/2024 competition. For the replica of an old arcade classic Battlezone

This engine was originally based on a similar Python project by StanislavPetrovV and another project created by tvytlx

Keybinds

All movement is relative to cameras rotation and position

KeyAction
KeyAMove left
KeyDMove right
KeyWMove forward
KeySMove backwards
KeySpaceMove up
KeyShiftMove down
KeyLeftRotate camera left
KeyRightRotate camera right
KeyUpRotate camera up
KeyDownRotate camera down

Development

This is a hobby project, open to contributions! Expect progress based on my free time.

FAQs

Package last updated on 21 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts