webgl3d

package
v0.0.0-...-be50a85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const InDegree = (180.0 / math.Pi)
View Source
const InRadian = (math.Pi / 180.0)

Variables

This section is empty.

Functions

func NewShader_3DAxes

func NewShader_3DAxes(wctx *wcommon.WebGLContext) *wcommon.Shader

func NewShader_ColorOnly

func NewShader_ColorOnly(wctx *wcommon.WebGLContext) *wcommon.Shader

func NewShader_InstancePoseColor

func NewShader_InstancePoseColor(wctx *wcommon.WebGLContext) *wcommon.Shader

func NewShader_NormalColor

func NewShader_NormalColor(wctx *wcommon.WebGLContext) *wcommon.Shader

func NewShader_NormalTexture

func NewShader_NormalTexture(wctx *wcommon.WebGLContext) *wcommon.Shader

func NewShader_TextureOnly

func NewShader_TextureOnly(wctx *wcommon.WebGLContext) *wcommon.Shader

Types

type Camera

type Camera struct {
	// contains filtered or unexported fields
}

func NewOrthographicCamera

func NewOrthographicCamera(wh [2]int, fov_in_clipwidth float32, zoom float32) *Camera

func NewPerspectiveCamera

func NewPerspectiveCamera(wh [2]int, fov_in_degree float32, zoom float32) *Camera

func (*Camera) GetCenter

func (self *Camera) GetCenter() [3]float32

func (*Camera) GetProjMatrix

func (self *Camera) GetProjMatrix() *geom3d.Matrix4

func (*Camera) GetViewMatrix

func (self *Camera) GetViewMatrix() *geom3d.Matrix4

func (*Camera) RotateAroundAxis

func (self *Camera) RotateAroundAxis(axis [3]float32, angle_in_degree float32) *Camera

func (*Camera) RotateAroundPoint

func (self *Camera) RotateAroundPoint(distance float32, h_angle float32, v_angle float32) *Camera

func (*Camera) RotateByPitch

func (self *Camera) RotateByPitch(angle_in_degree float32) *Camera

func (*Camera) RotateByRoll

func (self *Camera) RotateByRoll(angle_in_degree float32) *Camera

func (*Camera) RotateByYaw

func (self *Camera) RotateByYaw(angle_in_degree float32) *Camera

func (*Camera) SetAspectRatio

func (self *Camera) SetAspectRatio(width int, height int) *Camera

func (*Camera) SetPose

func (self *Camera) SetPose(from [3]float32, lookat [3]float32, up [3]float32) *Camera

func (*Camera) SetPoseWithCameraAxes

func (self *Camera) SetPoseWithCameraAxes(camX [3]float32, camY [3]float32, camZ [3]float32, center [3]float32) *Camera

func (*Camera) SetPoseWithMcw

func (self *Camera) SetPoseWithMcw(Mcw *geom3d.Matrix4) *Camera

func (*Camera) SetZoom

func (self *Camera) SetZoom(zoom float32) *Camera

func (*Camera) ShowInfo

func (self *Camera) ShowInfo()

func (*Camera) TestDataBuffer

func (self *Camera) TestDataBuffer(dbuffer []float32, stride int)

func (*Camera) Translate

func (self *Camera) Translate(tx float32, ty float32, tz float32) *Camera

type CameraProjection

type CameraProjection interface {
	IsPerspective() bool
	IsOrthographic() bool
	GetParameters() (wh [2]int, fov float32, zoom float32, nearfar [2]float32)
	GetMatrix() *geom3d.Matrix4
	SetAspectRatio(width int, height int)
	SetZoom(zoom float32)

	MultiplyVector3([3]float32) [3]float32 // only for test
}

type Geometry

type Geometry struct {
	// contains filtered or unexported fields
}

func NewGeometry

func NewGeometry() *Geometry

func NewGeometry_Cube

func NewGeometry_Cube(xsize float32, ysize float32, zsize float32) *Geometry

func NewGeometry_CubeWithTexture

func NewGeometry_CubeWithTexture(xsize float32, ysize float32, zsize float32) *Geometry

func NewGeometry_Cylinder

func NewGeometry_Cylinder(nsides int, radius float32, height float32, stt_angle float32, solid bool) *Geometry

func NewGeometry_EmptyExample

func NewGeometry_EmptyExample() *Geometry

func NewGeometry_Polygon

func NewGeometry_Polygon(n int, radius float32, starting_angle_in_degree float32) *Geometry

func NewGeometry_Pyramid

func NewGeometry_Pyramid(nsides int, radius float32, height float32, stt_angle float32, solid bool) *Geometry

func NewGeometry_SolidFromCentersAndRadii

func NewGeometry_SolidFromCentersAndRadii(centers [][3]float32, radii []float32, nsegments int) *Geometry

func NewGeometry_SolidFromFaceAndHeight

func NewGeometry_SolidFromFaceAndHeight(face [][3]float32, height float32) *Geometry

func NewGeometry_Sphere

func NewGeometry_Sphere(radius float32, wsegs int, hsegs int) *Geometry

func (*Geometry) AddEdge

func (self *Geometry) AddEdge(edge []uint32) uint32

func (*Geometry) AddFace

func (self *Geometry) AddFace(face []uint32) uint32

func (*Geometry) AddNormal

func (self *Geometry) AddNormal(normal_vector [3]float32) *Geometry

func (*Geometry) AddTextureUV

func (self *Geometry) AddTextureUV(tuv []float32) *Geometry

func (*Geometry) AddVertex

func (self *Geometry) AddVertex(coords [3]float32) uint32

func (*Geometry) AppyMatrix4

func (self *Geometry) AppyMatrix4(m *geom3d.Matrix4) *Geometry

func (*Geometry) BuildDataBuffers

func (self *Geometry) BuildDataBuffers(for_points bool, for_lines bool, for_faces bool)

func (*Geometry) BuildDataBuffersForWireframe

func (self *Geometry) BuildDataBuffersForWireframe()

func (*Geometry) BuildNormalsForFace

func (self *Geometry) BuildNormalsForFace()

func (*Geometry) BuildNormalsForVertex

func (self *Geometry) BuildNormalsForVertex()

func (*Geometry) BuildWebGLBuffers

func (self *Geometry) BuildWebGLBuffers(wctx *wcommon.WebGLContext, for_points bool, for_lines bool, for_faces bool)

func (*Geometry) ChangeNormal

func (self *Geometry) ChangeNormal(idx int, normal_vector [3]float32) *Geometry

func (*Geometry) Clear

func (self *Geometry) Clear(geom bool, data_buf bool, webgl_buf bool) *Geometry

func (*Geometry) GetFaceNormal

func (self *Geometry) GetFaceNormal(fidx int) [3]float32

func (*Geometry) GetVertexNormal

func (self *Geometry) GetVertexNormal(vidx int) [3]float32

func (*Geometry) GetWebGLBuffer

func (self *Geometry) GetWebGLBuffer(draw_mode int) (js.Value, int, [4]int)

func (*Geometry) HasNormalFor

func (self *Geometry) HasNormalFor(mode string) bool

func (*Geometry) HasTextureFor

func (self *Geometry) HasTextureFor(mode string) bool

func (*Geometry) IsDataBufferReady

func (self *Geometry) IsDataBufferReady() bool

func (*Geometry) IsWebGLBufferReady

func (self *Geometry) IsWebGLBufferReady() bool

func (*Geometry) Merge

func (self *Geometry) Merge(g *Geometry) *Geometry

func (*Geometry) Rotate

func (self *Geometry) Rotate(axis [3]float32, angle_in_degree float32) *Geometry

func (*Geometry) Scale

func (self *Geometry) Scale(sx float32, sy float32, sz float32) *Geometry

func (*Geometry) SetEdges

func (self *Geometry) SetEdges(edges [][]uint32) *Geometry

func (*Geometry) SetFaces

func (self *Geometry) SetFaces(faces [][]uint32) *Geometry

func (*Geometry) SetNormals

func (self *Geometry) SetNormals(normals [][3]float32) *Geometry

func (*Geometry) SetTextureUVs

func (self *Geometry) SetTextureUVs(tuvs [][]float32) *Geometry

func (*Geometry) SetVertices

func (self *Geometry) SetVertices(vertices [][3]float32) *Geometry

func (*Geometry) ShowInfo

func (self *Geometry) ShowInfo()

func (*Geometry) Translate

func (self *Geometry) Translate(tx float32, ty float32, tz float32) *Geometry

type Lighting

type Lighting struct {
}

func NewLighting

func NewLighting() *Lighting

type OrthographicProjection

type OrthographicProjection struct {
	// contains filtered or unexported fields
}

func NewOrthographicProjection

func NewOrthographicProjection(wh [2]int, fov_in_clipwidth float32, zoom float32, nearfar [2]float32) *OrthographicProjection

func (*OrthographicProjection) GetMatrix

func (self *OrthographicProjection) GetMatrix() *geom3d.Matrix4

func (*OrthographicProjection) GetParameters

func (self *OrthographicProjection) GetParameters() ([2]int, float32, float32, [2]float32)

func (*OrthographicProjection) IsOrthographic

func (self *OrthographicProjection) IsOrthographic() bool

func (*OrthographicProjection) IsPerspective

func (self *OrthographicProjection) IsPerspective() bool

func (*OrthographicProjection) MultiplyVector3

func (self *OrthographicProjection) MultiplyVector3(v [3]float32) [3]float32

func (*OrthographicProjection) SetAspectRatio

func (self *OrthographicProjection) SetAspectRatio(width int, height int)

func (*OrthographicProjection) SetNearFar

func (self *OrthographicProjection) SetNearFar(near float32, far float32)

func (*OrthographicProjection) SetZoom

func (self *OrthographicProjection) SetZoom(zoom float32)

type Overlay

type Overlay interface {
	Render(proj *geom3d.Matrix4, view *geom3d.Matrix4)
}

type OverlayLabel

type OverlayLabel struct {
	// contains filtered or unexported fields
}

func (*OverlayLabel) SetBackground

func (self *OverlayLabel) SetBackground(bkgtype string) *OverlayLabel

func (*OverlayLabel) SetCharacterWH

func (self *OverlayLabel) SetCharacterWH(chwh [2]float32) *OverlayLabel

func (*OverlayLabel) SetPose

func (self *OverlayLabel) SetPose(rotation float32, offset_reference string, offset [2]float32) *OverlayLabel

type OverlayLabelLayer

type OverlayLabelLayer struct {
	Labels []*OverlayLabel //
	// contains filtered or unexported fields
}

func NewOverlayLabelLayer

func NewOverlayLabelLayer(wctx *wcommon.WebGLContext, fontsize int, outlined bool) *OverlayLabelLayer

func (*OverlayLabelLayer) AddLabel

func (self *OverlayLabelLayer) AddLabel(labels ...*OverlayLabel) *OverlayLabelLayer

func (*OverlayLabelLayer) AddLabelsForTest

func (self *OverlayLabelLayer) AddLabelsForTest() *OverlayLabelLayer

func (*OverlayLabelLayer) AddTextLabel

func (self *OverlayLabelLayer) AddTextLabel(label_text string, xyz [3]float32, color string, offref string) *OverlayLabelLayer

func (*OverlayLabelLayer) CreateLabel

func (self *OverlayLabelLayer) CreateLabel(label_text string, xyz [3]float32, color string) *OverlayLabel

func (*OverlayLabelLayer) FindLabel

func (self *OverlayLabelLayer) FindLabel(label_text string) *OverlayLabel

func (*OverlayLabelLayer) Render

func (self *OverlayLabelLayer) Render(proj *geom3d.Matrix4, view *geom3d.Matrix4)

type OverlayMarkerLayer

type OverlayMarkerLayer struct {
	Markers []*SceneObject // list of OverlayMarkers to be rendered (in pixels in CAMERA space)
	// contains filtered or unexported fields
}

func NewOverlayMarkerLayer

func NewOverlayMarkerLayer(wctx *wcommon.WebGLContext) *OverlayMarkerLayer

func (*OverlayMarkerLayer) AddArrowHeadMarker

func (self *OverlayMarkerLayer) AddArrowHeadMarker(size float32, color string, outline_color string, rotation float32, xyz [3]float32) *OverlayMarkerLayer

func (*OverlayMarkerLayer) AddArrowMarker

func (self *OverlayMarkerLayer) AddArrowMarker(size float32, color string, outline_color string, rotation float32, xyz [3]float32) *OverlayMarkerLayer

func (*OverlayMarkerLayer) AddMarker

func (self *OverlayMarkerLayer) AddMarker(marker ...*SceneObject) *OverlayMarkerLayer

func (*OverlayMarkerLayer) AddMarkersForTest

func (self *OverlayMarkerLayer) AddMarkersForTest() *OverlayMarkerLayer

func (*OverlayMarkerLayer) AddSpriteMarker

func (self *OverlayMarkerLayer) AddSpriteMarker(imgpath string, color string, wh [2]float32, xyz [3]float32, offref string) *OverlayMarkerLayer

func (*OverlayMarkerLayer) CreateArrowHeadMarker

func (self *OverlayMarkerLayer) CreateArrowHeadMarker(size float32, color string, outline_color string, use_poses bool) *SceneObject

func (*OverlayMarkerLayer) CreateArrowMarker

func (self *OverlayMarkerLayer) CreateArrowMarker(size float32, color string, outline_color string, use_poses bool) *SceneObject

func (*OverlayMarkerLayer) CreateSpriteMarker

func (self *OverlayMarkerLayer) CreateSpriteMarker(imgpath string, color string, wh [2]float32, offref string, use_poses bool) *SceneObject

func (*OverlayMarkerLayer) GetShaderForMarker

func (self *OverlayMarkerLayer) GetShaderForMarker(use_poses bool) *wcommon.Shader

func (*OverlayMarkerLayer) GetShaderForSpriteMarker

func (self *OverlayMarkerLayer) GetShaderForSpriteMarker(wh [2]float32, offrot [3]float32, use_poses bool) *wcommon.Shader

func (*OverlayMarkerLayer) Render

func (self *OverlayMarkerLayer) Render(proj *geom3d.Matrix4, vwmd *geom3d.Matrix4)

type PerspectiveProjection

type PerspectiveProjection struct {
	// contains filtered or unexported fields
}

func NewPerspectiveProjection

func NewPerspectiveProjection(wh [2]int, fov_in_degree float32, zoom float32, nearfar [2]float32) *PerspectiveProjection

func (*PerspectiveProjection) GetMatrix

func (self *PerspectiveProjection) GetMatrix() *geom3d.Matrix4

func (*PerspectiveProjection) GetParameters

func (self *PerspectiveProjection) GetParameters() ([2]int, float32, float32, [2]float32)

func (*PerspectiveProjection) IsOrthographic

func (self *PerspectiveProjection) IsOrthographic() bool

func (*PerspectiveProjection) IsPerspective

func (self *PerspectiveProjection) IsPerspective() bool

func (*PerspectiveProjection) MultiplyVector3

func (self *PerspectiveProjection) MultiplyVector3(v [3]float32) [3]float32

func (*PerspectiveProjection) SetAspectRatio

func (self *PerspectiveProjection) SetAspectRatio(width int, height int)

func (*PerspectiveProjection) SetZoom

func (self *PerspectiveProjection) SetZoom(zoom float32)

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(wctx *wcommon.WebGLContext) *Renderer

func (*Renderer) Clear

func (self *Renderer) Clear(scene *Scene)

func (*Renderer) RenderAxes

func (self *Renderer) RenderAxes(camera *Camera, length float32)

func (*Renderer) RenderScene

func (self *Renderer) RenderScene(scene *Scene, camera *Camera)

func (*Renderer) RenderSceneObject

func (self *Renderer) RenderSceneObject(scnobj *SceneObject, proj *geom3d.Matrix4, vwmd *geom3d.Matrix4) error

type Scene

type Scene struct {
	// contains filtered or unexported fields
}

func NewScene

func NewScene(bkg_color string) *Scene

func (*Scene) Add

func (self *Scene) Add(scnobj ...*SceneObject) *Scene

func (*Scene) AddOverlay

func (self *Scene) AddOverlay(overlay ...Overlay) *Scene

func (*Scene) Get

func (self *Scene) Get(indices ...int) *SceneObject

func (*Scene) GetBkgColor

func (self *Scene) GetBkgColor() [3]float32

func (*Scene) SetBkgColor

func (self *Scene) SetBkgColor(color string) *Scene

type SceneObject

type SceneObject struct {
	Geometry wcommon.Geometry  // geometry interface
	Material *wcommon.Material // material
	VShader  *wcommon.Shader   // vert shader and its bindings
	EShader  *wcommon.Shader   // edge shader and its bindings
	FShader  *wcommon.Shader   // face shader and its bindings

	UseDepth bool // depth test flag (default is true)
	UseBlend bool // blending flag with alpha (default is false)
	// contains filtered or unexported fields
}

func NewSceneObject

func NewSceneObject(geometry wcommon.Geometry, material *wcommon.Material,
	vshader *wcommon.Shader, eshader *wcommon.Shader, fshader *wcommon.Shader) *SceneObject

func NewSceneObject_3DAxes

func NewSceneObject_3DAxes(wctx *wcommon.WebGLContext, length float32) *SceneObject

func NewSceneObject_Airplane

func NewSceneObject_Airplane(wctx *wcommon.WebGLContext) *SceneObject

func NewSceneObject_CubeInstances

func NewSceneObject_CubeInstances(wctx *wcommon.WebGLContext) *SceneObject

func NewSceneObject_CubeWithTexture

func NewSceneObject_CubeWithTexture(wctx *wcommon.WebGLContext) *SceneObject

func NewSceneObject_CylinderWireframe

func NewSceneObject_CylinderWireframe(wctx *wcommon.WebGLContext) *SceneObject

func (*SceneObject) AddChild

func (self *SceneObject) AddChild(child *SceneObject) *SceneObject

func (*SceneObject) GetChildren

func (self *SceneObject) GetChildren() []*SceneObject

func (*SceneObject) GetModelMatrix

func (self *SceneObject) GetModelMatrix() *geom3d.Matrix4

func (*SceneObject) Rotate

func (self *SceneObject) Rotate(axis [3]float32, angle_in_degree float32) *SceneObject

func (*SceneObject) Scale

func (self *SceneObject) Scale(sx float32, sy float32, sz float32) *SceneObject

func (*SceneObject) SetPoseValues

func (self *SceneObject) SetPoseValues(index int, offset int, values ...float32) *SceneObject

func (*SceneObject) SetPoses

func (self *SceneObject) SetPoses(poses *wcommon.SceneObjectPoses) *SceneObject

func (*SceneObject) SetTransformation

func (self *SceneObject) SetTransformation(txyz [3]float32, axis [3]float32, angle_in_degree float32, sxyz [3]float32) *SceneObject

func (*SceneObject) SetupPoses

func (self *SceneObject) SetupPoses(size int, count int, data []float32) *SceneObject

func (*SceneObject) ShowInfo

func (self *SceneObject) ShowInfo()

func (*SceneObject) Translate

func (self *SceneObject) Translate(tx float32, ty float32, tz float32) *SceneObject

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL