1. Products
  2.   3D
  3.   GO
  4.   Pinhole
 
  

Free Go Library for 3D Wireframe Drawing

Open Source Go 3D Library for 3D Wireframe Drawing. It allows Software Developers to Create and Manage 3D Scene, Render 3D Files via Simple API for Visualizing Data Structures.

What is Pinhole Library?

In the ever-evolving world of programming, new tools continually expand creative possibilities—and Pinhole stands out as a powerful open source Go 3D API for 3D wireframe drawing. This free 3D Go API lets software developers create 3D wireframe drawings, render 3D files, and design complex visualizations without mastering low-level graphics algorithms. With its clean and accessible interface, Pinhole makes it simple to create 3D objects, define custom objects, and build immersive 3D scenes. Whether you want to add a new circle, transform an existing circle, or manage an entire 3D scene, Pinhole empowers both beginners and experienced developers to focus on creativity rather than complexity.

What makes Pinhole especially appealing is its intuitive API for versatile object creation and seamless scene management. Software developers can easily set viewpoints, manipulate shapes, and bring wireframe concepts to life without a steep learning curve. Ideal for designers, educators, artists, and curious coders alike, Pinhole turns creating 3D objects and rendering them into an enjoyable, straightforward process. By abstracting away intricate rendering logic, it enables anyone to experiment, innovate, and craft visually engaging 3D wireframe visualizations. If you’re looking to explore the world of 3D wireframe drawing in Go, Pinhole offers the perfect balance of simplicity, flexibility, and creative freedom.

Previous Next

Getting Started with Pinhole

The recommend way to install Pinhole is using GitHub. Please use the following command for a smooth installation.

Install Pinhole API via Get command

$ go get -u github.com/tidwall/pinhole 

You can download the compiled shared library from Github repository.

Create and Manage 3D Scene via Go API

The open source Pinhole library allows software developers to create and manage 3D scene inside their own Go applications. The library has included support for several important features, such as creating a basic 3D scene, adding objects, configuring the camera, rendering the scene and many more. The library has provides a variety of primitive 3D shapes that you can use in your scene. It is also possible to create custom objects by defining vertices, edges, or faces and add them to your scene. The following example shows how software developers can create a 3D scene using Go commands.

How to Create a Basic 3D Scene via Go Library?

import "github.com/tidwall/pinhole"

// Initialize the Scene
scene := pinhole.NewScene()

// Create 3D Objects:
cube := pinhole.NewCube()

//create custom objects and added to the scene
triangle := pinhole.NewObject()
triangle.Vertices = []pinhole.Vertex{
    {X: 0, Y: 0, Z: 0},
    {X: 1, Y: 0, Z: 0},
    {X: 0, Y: 1, Z: 0},
}
triangle.Edges = []pinhole.Edge{
    {0, 1},
    {1, 2},
    {2, 0},
}

scene.AddObject(cube)
scene.AddObject(triangle)

// Configure the Camera

camera := pinhole.NewCamera()
camera.Position = pinhole.Vector{X: 0, Y: 0, Z: 5} // Adjust the camera position
camera.Target = pinhole.Vector{X: 0, Y: 0, Z: 0}   // Set the camera's target (where it's looking)
scene.SetCamera(camera)

// Render the Scene and display out

renderer := pinhole.NewRenderer(scene)
renderer.Render()

Rendering Customization & Camera Control

Software Developers can customize the rendering style of wireframe scenes with options for line colors, thickness, and background settings. This flexibility empowers software developers to achieve their desired visual aesthetics. Moreover, the library provides powerful camera controls, enabling software developers to adjust camera position, orientation, and projection settings. This feature allows for dynamic exploration of 3D scenes and enhances user interactivity.

Versatile Object Creation via Go API

The Pinhole library has included a wide range of primitive shapes such as cubes, spheres, and cones, making it easy to create common 3D objects. Additionally, developers can define custom objects by specifying vertices, edges, and faces, allowing for the creation of complex and unique wireframe scenes. Engineers and designers can use the library to quickly prototype and visualize 3D models, aiding in the evaluation of designs and identification of potential issues before committing to full-scale development.

How to Add, Rotate, and Transform a Circle via Go API?

p := pinhole.New()
p.DrawCube(-0.3, -0.3, -0.3, 0.3, 0.3, 0.3)
p.Rotate(math.Pi/3, math.Pi/6, 0)

p.Begin()
p.DrawCircle(0, 0, 0, 0.2)
p.Rotate(0, math.Pi/2, 0)
p.Translate(-0.6, -0.4, 0)
p.Colorize(color.RGBA{255, 0, 0, 255})
p.End()

p.SavePNG("cube.png", 500, 500, nil)