whispervis/material.go

39 lines
1.1 KiB
Go
Raw Normal View History

2018-09-05 17:09:56 +03:00
package main
2018-09-20 15:41:24 +03:00
import "github.com/divan/three"
2018-09-05 17:09:56 +03:00
2018-09-20 22:16:21 +03:00
var (
2018-10-24 10:34:35 +02:00
DefaultNodeMaterial = NewNodeMaterial()
TransparentNodeMaterial = NewTransparentNodeMaterial()
DefaultEdgeMaterial = NewEdgeMaterial()
2018-09-20 22:16:21 +03:00
)
const DefaultTransparency = 0.9
2018-10-20 23:09:27 +02:00
2018-09-20 22:16:21 +03:00
// NewNodeMaterial creates a new default material for the graph node.
2018-09-05 17:09:56 +03:00
func NewNodeMaterial() three.Material {
params := three.NewMaterialParameters()
2018-10-22 14:40:41 +02:00
params.Color = three.NewColorRGB(0, 255, 0)
params.Transparent = false
2018-10-20 23:09:27 +02:00
params.Opacity = DefaultTransparency
2018-09-05 17:09:56 +03:00
return three.NewMeshPhongMaterial(params)
}
2018-10-24 10:34:35 +02:00
// NewTransparentNodeMaterial creates a new transparent material for the graph normal node.
func NewTransparentNodeMaterial() three.Material {
params := three.NewMaterialParameters()
params.Color = three.NewColorRGB(0, 255, 0)
params.Transparent = true
params.Opacity = 0.7
2018-10-24 10:34:35 +02:00
return three.NewMeshPhongMaterial(params)
}
2018-09-05 17:09:56 +03:00
// NewEdgeMaterial creates a new default material for the graph edge lines.
2018-09-20 22:16:21 +03:00
func NewEdgeMaterial() three.Material {
2018-09-05 17:09:56 +03:00
params := three.NewMaterialParameters()
2018-10-22 15:03:19 +02:00
params.Color = three.NewColorHex(0xf0f0f0)
params.Transparent = true
params.Opacity = 0.7
2018-09-05 17:09:56 +03:00
return three.NewLineBasicMaterial(params)
}