viewport3d

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package viewport3d is the 3D view of Glutter for CAD and games (SPEC §27.8): a Camera with CAD navigation, and, in later steps, a Scene of meshes, materials, lines, points and edges, section planes, picking and overlays.

The camera orbits a target at a distance, as a CAD viewer's does. It works in float64 (D30, package vecmath) and gives the GPU float32 matrices relative to the eye, so that a scene 50 km wide with a detail of 0.1 mm draws without jitter: Camera.ModelView subtracts the eye from the item's translation in float64 before the matrices go to float32. The projections are reversed-Z with an infinite far plane (perspective) and WebGPU's clip space (SPEC §27.1).

Navigation is a widget, NewNavigation, whose gesture recognizers take part in Glutter's gesture arena, so a recognizer above the view (a button over it, a drag of a parent) still wins or loses the arena as in Flutter. Its defaults are the table of SPEC §27.8, and NavigationOpts changes them.

Everything here runs on the UI thread (SPEC §13).

Flutter: no counterpart

Index

Constants

View Source
const AllLayers = ^uint32(0)

AllLayers is the layer mask of an item or a view that is in every layer.

Flutter: no counterpart

View Source
const MaxSectionPlanes = 6

MaxSectionPlanes is how many section planes a scene has.

Flutter: no counterpart

View Source
const TagEnvironmentInvalid = "EnvironmentInvalid"

TagEnvironmentInvalid is the tag of the panic of NewEnvironment for a texture that is not a cube of a format it reads.

Flutter: no counterpart

View Source
const TagItemInvalid = "ItemInvalid"

TagItemInvalid is the tag of the panic of NewItem and Item.SetMaterial for a mesh and a material that do not go together (a mesh of lines with a material of triangles, ...), or for a missing mesh or material. Programmer errors panic in debug builds (SPEC §14).

Flutter: no counterpart

View Source
const TagMeshInvalid = "MeshInvalid"

TagMeshInvalid is the tag of the error of NewMesh and FeatureEdges for data that cannot make a mesh.

Flutter: no counterpart

View Source
const TagPickUnavailable = "PickUnavailable"

TagPickUnavailable is the tag of the error of a pick that cannot be made: the view has no renderer or no GPU device, or the renderer was disposed while the pick waited for its frame.

Flutter: no counterpart

View Source
const TagSectionInvalid = "SectionInvalid"

TagSectionInvalid is the tag of the panic of SetSectionPlanes for more planes than MaxSectionPlanes or a plane whose normal has no length. Programmer errors panic in debug builds (SPEC §14); a release build keeps the first planes it can use.

Flutter: no counterpart

View Source
const TagUploadFailed = "ModelUploadFailed"

TagUploadFailed is the tag of the error of Upload when the context is done before it has made all the items. The cause is the context's error.

Flutter: no counterpart

View Source
const TagViewInvalid = "Viewport3DViewInvalid"

TagViewInvalid is the tag of the panic of NewView for arguments that are not valid (SPEC §27.8).

Variables

This section is empty.

Functions

This section is empty.

Types

type AlphaMode

type AlphaMode int

AlphaMode is how the alpha of a PBRMaterial is used (glTF's alphaMode).

Flutter: no counterpart

const (
	// AlphaModeOpaque ignores the alpha; the zero value.
	AlphaModeOpaque AlphaMode = iota
	// AlphaModeMask draws a pixel whose alpha is at least the cutoff and none otherwise.
	AlphaModeMask
	// AlphaModeBlend blends by the alpha: the items are transparent (sorted back to front, no depth write).
	AlphaModeBlend
)

type Anchored

type Anchored struct {
	widgets.SingleChildRenderObjectWidget
	// contains filtered or unexported fields
}

Anchored is a widget of a view that follows a point of the world (SPEC §27.8, "Overlays"): the label of a part, a dimension, a marker. Give it to ViewOpts.Children. At each layout the view puts the child at the point's place in the picture (Camera.Project), so the child moves with the camera, and it is hidden, with no painting, no hit testing and no semantics, while the point is behind the camera or the child is outside the view, and, with HideWhenCovered, while something is in front of the point. A child that is not an Anchored fills the view. The children are over the picture, in the order they are given, and the pointer reaches them before the navigation, so a label can be tapped and a tap elsewhere orbits.

Flutter: no counterpart

func NewAnchored

func NewAnchored(point vecmath.Vec3, child widgets.Widget, opts ...AnchoredOpts) *Anchored

NewAnchored creates a widget that follows a point of the world, in float64.

Flutter: no counterpart

func (*Anchored) CreateRenderObject

func (a *Anchored) CreateRenderObject(widgets.BuildContext) rendering.RenderObject

CreateRenderObject creates the render object.

Flutter: no counterpart

func (*Anchored) Point

func (a *Anchored) Point() vecmath.Vec3

Point is the point of the world that the child follows.

Flutter: no counterpart

func (*Anchored) UpdateRenderObject

func (a *Anchored) UpdateRenderObject(_ widgets.BuildContext, ro rendering.RenderObject)

UpdateRenderObject copies the configuration to the render object.

Flutter: no counterpart

type AnchoredOpts

type AnchoredOpts struct {
	// Key is the key of the widget.
	Key foundation.Key
	// Alignment is the point of the child that is put on the anchor: Alignment{X: -1, Y: -1} is its top left corner, {X: 0, Y: 0}
	// (the default) its center and {X: 0, Y: 1} the middle of its bottom edge.
	Alignment painting.Alignment
	// Offset moves the child from the anchor, in logical pixels.
	Offset ui.Offset
	// HideWhenCovered hides the child while another item of the scene is between it and the camera, by the depth of the picture
	// (one pick, read back, in each frame that draws the scene, for each such child; none while there are no such children). The
	// answer comes with the frame after the one that drew.
	HideWhenCovered bool
}

AnchoredOpts are the optional parameters of NewAnchored.

Flutter: no counterpart

type AnimateOpts

type AnimateOpts struct {
	// Duration is the length of the move; the default is 300 ms, and Some(0) moves at once.
	Duration foundation.Opt[time.Duration]
	// Curve shapes the move; the default is animation.Curves.EaseInOut.
	Curve animation.Curve
	// OnEnd is called when the move ends: with true when the camera reached the pose, with false when another move or the
	// user's input stopped it.
	OnEnd func(completed bool)
}

AnimateOpts are the optional parameters of Camera.AnimateTo.

Flutter: no counterpart

type Animation

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

Animation plays a model.Animation: it gives the pose at a time (SPEC §28.5). It has no blending and no state: the app chooses the time (looping it as it likes) and the animation to sample.

Flutter: no counterpart

func NewAnimation

func NewAnimation(a *model.Animation) *Animation

NewAnimation makes the player of an animation of a model.

Flutter: no counterpart

func (*Animation) Duration

func (a *Animation) Duration() float32

Duration is the time of the last keyframe, in seconds.

Flutter: no counterpart

func (*Animation) Name

func (a *Animation) Name() string

Name is the name of the animation.

Flutter: no counterpart

func (*Animation) Sample

func (a *Animation) Sample(t float32, p *Pose)

Sample writes the value of every channel at the time t (in seconds) into the pose, over what it had for those nodes and parts. Before the first keyframe a channel has the first value and after the last one the last value: looping is the caller's. The interpolation of a channel is its own: STEP keeps a value until the next time, LINEAR blends (rotations on the shortest arc), and CUBICSPLINE is the cubic Hermite spline of the specification (glTF 2.0, appendix C), whose rotations are normalized.

Flutter: no counterpart

type Axes

type Axes struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Axes is a small picture of the world's axes as the camera sees them, for a corner of a view (SPEC §27.8, "Overlays"): a line from the center for each positive axis with its name at the tip, and a short dim stub for the negative one. It turns with the camera and costs nothing while the camera stands still. NewView draws one in a corner with ViewOpts.Axes.

Flutter: no counterpart

func NewAxes

func NewAxes(camera *Camera, opts ...AxesOpts) *Axes

NewAxes creates the axes of a camera.

Flutter: no counterpart

func (*Axes) Camera

func (a *Axes) Camera() *Camera

Camera is the camera that the axes follow.

Flutter: no counterpart

func (*Axes) CreateState

func (a *Axes) CreateState() widgets.State

CreateState creates the state of the widget.

Flutter: no counterpart

type AxesOpts

type AxesOpts struct {
	// Key is the key of the widget.
	Key foundation.Key
	// Size is the width and the height of the widget in logical pixels; the default is 72.
	Size float64
	// Colors are the colors of the x, y and z axes; the defaults are red, green and blue. A zero color is the default.
	Colors [3]ui.Color
	// Labels are the names of the axes; the defaults are "X", "Y" and "Z". An empty one is the default.
	Labels [3]string
	// SemanticsLabel describes the axes to assistive technology; the default is "Axes".
	SemanticsLabel string
}

AxesOpts are the optional parameters of NewAxes.

Flutter: no counterpart

type Camera

type Camera struct {
	foundation.ChangeNotifier
	// contains filtered or unexported fields
}

Camera is the point of view of a 3D view: it orbits a target at a distance, with a perspective or an orthographic projection. It is a Listenable: it notifies its listeners when anything that changes the picture changes (the view listens to it to draw). It keeps float64 numbers (D30); ModelView and ModelViewProjection give the GPU matrices that are relative to the eye.

The camera looks along its orientation's -z, with y up; a pixel of the view is a logical pixel of its widget, with the origin at the top left. Use it on the UI thread.

Flutter: no counterpart

func NewCamera

func NewCamera(opts ...CameraOpts) *Camera

NewCamera creates a camera that looks at the origin from a distance of 10, down -z.

Flutter: no counterpart

func (*Camera) AnimateTo

func (c *Camera) AnimateTo(pose CameraPose, vsync scheduler.TickerProvider, opts ...AnimateOpts)

AnimateTo moves the camera to the pose over a time, with an AnimationController on the ticker provider that the caller gives (a State embeds SingleTickerProvider). The camera turns by the shortest arc, and the distance changes by the same factor in each frame. A move that starts stops the one that is running; so does SetPose and the user's navigation.

Flutter: no counterpart

func (*Camera) Animating

func (c *Camera) Animating() bool

Animating says whether a move is running.

Flutter: no counterpart

func (*Camera) Bounds

func (c *Camera) Bounds() vecmath.Box3

Bounds is the box of the scene that the near plane and FitTo are made from; it is empty until SetBounds.

Flutter: no counterpart

func (*Camera) Dispose

func (c *Camera) Dispose()

Dispose stops an animation and releases the camera's listeners.

Flutter: no counterpart

func (*Camera) Distance

func (c *Camera) Distance() float64

Distance is the distance from the eye to the target.

Flutter: no counterpart

func (*Camera) Eye

func (c *Camera) Eye() vecmath.Vec3

Eye is where the camera is.

Flutter: no counterpart

func (*Camera) Far

func (c *Camera) Far() float64

Far is the distance of the far plane: infinity for a perspective camera.

Flutter: no counterpart

func (*Camera) FieldOfView

func (c *Camera) FieldOfView() float64

FieldOfView is the vertical angle of view in radians.

Flutter: no counterpart

func (*Camera) FitPose

func (c *Camera) FitPose(box vecmath.Box3) CameraPose

FitPose is the pose that shows a box whole, with the camera's orientation: the target is the box's center and the distance the smallest at which the corners are in the view, with a small margin. An empty box gives the current pose.

Flutter: no counterpart

func (*Camera) FitTo

func (c *Camera) FitTo(box vecmath.Box3)

FitTo moves the target to the center of the box and the eye to the distance at which the whole box is in the view (see FitPose), keeping the orientation.

Flutter: no counterpart

func (*Camera) FocalPoint

func (c *Camera) FocalPoint(at ui.Offset) vecmath.Vec3

FocalPoint returns the point under a point of the view that is on the plane through the target, perpendicular to the line of sight: where a navigation without a depth to go by takes the point it zooms or turns around.

Flutter: no counterpart

func (*Camera) Forward

func (c *Camera) Forward() vecmath.Vec3

Forward is the direction that the camera looks in.

Flutter: no counterpart

func (*Camera) Frustum

func (c *Camera) Frustum() vecmath.Frustum

Frustum is the volume that the camera sees, in world coordinates.

Flutter: no counterpart

func (*Camera) Kind

func (c *Camera) Kind() ProjectionKind

Kind is the projection of the camera.

Flutter: no counterpart

func (*Camera) ModelView

func (c *Camera) ModelView(world vecmath.Mat4) [16]float32

ModelView is the float32 matrix that takes the vertices of an item (relative to its mesh's origin) into the view, for an item whose float64 transform is world (D30). The matrix works in a world whose origin is the eye, so the GPU's float32 sees small numbers near the camera. The item's world transform must hold the mesh's origin.

Flutter: no counterpart

func (*Camera) ModelViewProjection

func (c *Camera) ModelViewProjection(world vecmath.Mat4) [16]float32

ModelViewProjection is ModelView with the projection: the float32 matrix that takes an item's vertices into clip space.

Flutter: no counterpart

func (*Camera) Near

func (c *Camera) Near() float64

Near is the distance of the near plane. A perspective camera takes it from the scene's bounds: half the distance to the nearest point that the scene's bounding sphere can have, so that nothing of the scene is cut, and a hundredth of the target's distance when the eye is inside the sphere. CameraOpts.Near sets it instead. An orthographic camera's near plane is the front of the bounding sphere, which may be behind the eye (a negative distance).

Flutter: no counterpart

func (*Camera) Orbit

func (c *Camera) Orbit(yaw, pitch float64)

Orbit turns the camera around the target: yaw radians counterclockwise as seen from above (around Up), and pitch radians upwards (the camera rises). The elevation stops short of the pole (CameraOpts.ElevationLimit).

Flutter: no counterpart

func (*Camera) OrbitAround

func (c *Camera) OrbitAround(pivot vecmath.Vec3, yaw, pitch float64)

OrbitAround turns the camera around a point, which stays where it is on the screen. See Orbit.

Flutter: no counterpart

func (*Camera) Orientation

func (c *Camera) Orientation() vecmath.Quat

Orientation turns the camera's axes into the world's: the camera looks along Orientation*(0, 0, -1).

Flutter: no counterpart

func (*Camera) Pan

func (c *Camera) Pan(dx, dy float64)

Pan moves the camera and its target across the view by a distance in logical pixels, as dragging the scene would: the point under the target stays under the pointer. dx is to the right and dy is down.

Flutter: no counterpart

func (*Camera) Pose

func (c *Camera) Pose() CameraPose

Pose is where the camera looks from.

Flutter: no counterpart

func (*Camera) Project

func (c *Camera) Project(p vecmath.Vec3) (ui.Offset, bool)

Project returns the point of the view, in logical pixels, where a point of the world is drawn, and false when the point is behind a perspective camera.

Flutter: no counterpart

func (*Camera) ProjectNDC

func (c *Camera) ProjectNDC(p vecmath.Vec3) (vecmath.Vec3, bool)

ProjectNDC returns the normalized device coordinates of a point of the world: x and y from -1 to 1, and the depth from 0 (far) to 1 (near) of reversed-Z. It returns false for a point behind a perspective camera.

Flutter: no counterpart

func (*Camera) ProjectionMatrix

func (c *Camera) ProjectionMatrix() vecmath.Mat4

ProjectionMatrix is the projection in float64, in WebGPU's clip space with reversed-Z (SPEC §27.7).

Flutter: no counterpart

func (*Camera) Ray

func (c *Camera) Ray(at ui.Offset) vecmath.Ray

Ray is the ray of the line of sight through a point of the view, in logical pixels: it starts at the eye (perspective) or in the plane of the eye (orthographic), and its direction has length 1.

Flutter: no counterpart

func (*Camera) RelativeToEye

func (c *Camera) RelativeToEye(world vecmath.Mat4) vecmath.Mat4

RelativeToEye returns the transform of an item with the eye taken off its translation, in float64: the model matrix of an item in a world whose origin is the eye. Where the item is far from the world's origin the subtraction is exact in float64, and what is left is small near the eye (D30).

Flutter: no counterpart

func (*Camera) RelativeViewMatrix

func (c *Camera) RelativeViewMatrix() vecmath.Mat4

RelativeViewMatrix turns directions of the world into directions of the view: the view matrix without the eye's translation. The GPU matrices use it with points that are relative to the eye.

Flutter: no counterpart

func (*Camera) Right

func (c *Camera) Right() vecmath.Vec3

Right is the direction to the right of the view.

Flutter: no counterpart

func (*Camera) Roll

func (c *Camera) Roll(angle float64)

Roll turns the camera around its line of sight by the angle in radians: positive is clockwise as the viewer sees it, which turns the scene counterclockwise.

Flutter: no counterpart

func (*Camera) SetBounds

func (c *Camera) SetBounds(b vecmath.Box3)

SetBounds tells the camera how big the scene is. The near plane is made from it, and a double click fits it.

Flutter: no counterpart

func (*Camera) SetDistance

func (c *Camera) SetDistance(d float64)

SetDistance moves the eye along the line of sight, to the distance from the target, within the camera's limits.

Flutter: no counterpart

func (*Camera) SetFieldOfView

func (c *Camera) SetFieldOfView(fovY float64)

SetFieldOfView changes the vertical angle of view, in radians, which must be between 0 and pi.

Flutter: no counterpart

func (*Camera) SetKind

func (c *Camera) SetKind(k ProjectionKind)

SetKind changes the projection. The view keeps the size of what is at the target.

Flutter: no counterpart

func (*Camera) SetOrientation

func (c *Camera) SetOrientation(q vecmath.Quat)

SetOrientation turns the camera around the target.

Flutter: no counterpart

func (*Camera) SetPose

func (c *Camera) SetPose(p CameraPose)

SetPose puts the camera in the pose, within its limits, and stops an animation.

Flutter: no counterpart

func (*Camera) SetStandardView

func (c *Camera) SetStandardView(v StandardView)

SetStandardView turns the camera to a standard view at once. AnimateTo(StandardViewPose(v), vsync) moves there instead.

Flutter: no counterpart

func (*Camera) SetTarget

func (c *Camera) SetTarget(t vecmath.Vec3)

SetTarget moves the target; the eye moves with it.

Flutter: no counterpart

func (*Camera) SetViewportSize

func (c *Camera) SetViewportSize(s ui.Size)

SetViewportSize tells the camera the size of its view in logical pixels. The widget does it at layout; it does not notify, since the widget redraws.

Flutter: no counterpart

func (*Camera) StandardViewOrientation

func (c *Camera) StandardViewOrientation(v StandardView) vecmath.Quat

StandardViewOrientation is the orientation of a standard view: the camera looks at the model along an axis (or the diagonal of the isometric view) with the world's up upwards in the view. The top and bottom views have the back and the front of the model upwards. Right-handed, with the right of the front view at Up x Front.

Flutter: no counterpart

func (*Camera) StandardViewPose

func (c *Camera) StandardViewPose(v StandardView) CameraPose

StandardViewPose is the pose of a standard view of what the camera looks at: the same target and distance, the view's orientation.

Flutter: no counterpart

func (*Camera) StopAnimation

func (c *Camera) StopAnimation()

StopAnimation stops a running move where it is, and releases its controller.

Flutter: no counterpart

func (*Camera) Target

func (c *Camera) Target() vecmath.Vec3

Target is the point that the camera looks at and orbits.

Flutter: no counterpart

func (*Camera) Unproject

func (c *Camera) Unproject(at ui.Offset, depth float64) (vecmath.Vec3, bool)

Unproject returns the point of the world that is drawn at a point of the view with a depth of reversed-Z (what a pick reads back, SPEC §27.8), and false when the depth is 0 or less for a perspective camera: that point is at infinity.

Flutter: no counterpart

func (*Camera) Up

func (c *Camera) Up() vecmath.Vec3

Up is the direction that is up in the world.

Flutter: no counterpart

func (*Camera) ViewDirectionOrientation

func (c *Camera) ViewDirectionOrientation(dir vecmath.Vec3) vecmath.Quat

ViewDirectionOrientation is the orientation of a view of the model from a direction (from the model to the viewer, in the world; it need not be a unit vector) with the world's up upwards in the view, as the standard views have it. When the direction is that of the up axis (the top and bottom views) the front of the model is downwards in the view, as in StandardViewTop and StandardViewBottom. The view cube goes to its edges and corners with it. A direction with no length gives the camera's own orientation.

Flutter: no counterpart

func (*Camera) ViewDirectionPose

func (c *Camera) ViewDirectionPose(dir vecmath.Vec3) CameraPose

ViewDirectionPose is the pose of a view from a direction (ViewDirectionOrientation) of what the camera looks at: the same target and distance.

Flutter: no counterpart

func (*Camera) ViewMatrix

func (c *Camera) ViewMatrix() vecmath.Mat4

ViewMatrix turns points of the world into points of the view, in float64.

Flutter: no counterpart

func (*Camera) ViewProjectionMatrix

func (c *Camera) ViewProjectionMatrix() vecmath.Mat4

ViewProjectionMatrix is the projection times the view, in float64.

Flutter: no counterpart

func (*Camera) ViewUp

func (c *Camera) ViewUp() vecmath.Vec3

ViewUp is the direction to the top of the view, which differs from Up when the camera looks up or down or has rolled.

Flutter: no counterpart

func (*Camera) ViewportSize

func (c *Camera) ViewportSize() ui.Size

ViewportSize is the size of the view in logical pixels, as the widget told the camera.

Flutter: no counterpart

func (*Camera) Zoom

func (c *Camera) Zoom(factor float64)

Zoom moves the eye towards the target when the factor is below 1 and away when it is above: the distance is multiplied by it, within the camera's limits.

Flutter: no counterpart

func (*Camera) ZoomAt

func (c *Camera) ZoomAt(factor float64, at ui.Offset)

ZoomAt is Zoom that keeps the point of the world under a point of the view (FocalPoint) where it is on the screen.

Flutter: no counterpart

func (*Camera) ZoomToward

func (c *Camera) ZoomToward(factor float64, point vecmath.Vec3)

ZoomToward is Zoom that keeps a point of the world where it is on the screen: the eye moves along the line to the point, and the target with it.

Flutter: no counterpart

type CameraOpts

type CameraOpts struct {
	// Projection is the kind of projection; the default is perspective.
	Projection ProjectionKind
	// FieldOfView is the vertical angle of view in radians, of a perspective projection; the default is pi/4. An
	// orthographic projection takes it too: its view is as tall as a perspective one at the target's distance, so that a
	// switch between the two keeps the size of what is at the target.
	FieldOfView float64
	// Target is the point that the camera looks at; the default is the origin.
	Target vecmath.Vec3
	// Distance is the distance from the eye to the target; the default is 10.
	Distance float64
	// Orientation turns the camera; the zero value is the identity: it looks down -z, with +y up.
	Orientation vecmath.Quat
	// Up is the direction that is up in the world, which the orbit turns around and the standard views use; the default
	// is +y.
	Up vecmath.Vec3
	// Front is the direction from the model to the viewer in the front view; the default is +z for a world with +y up, and
	// -y for one with +z up.
	Front vecmath.Vec3
	// MinDistance and MaxDistance limit the distance of the eye to the target; the defaults are 1e-9 and 1e15.
	MinDistance, MaxDistance float64
	// ElevationLimit is how far, in radians, the orbit may raise or lower the camera above the horizontal, which stops it
	// short of the pole, where the camera would flip. The default is 89.5 degrees; pi/2 or more removes the limit.
	ElevationLimit float64
	// Near sets the near plane of a perspective projection, instead of the one made from the scene's bounds.
	Near float64
}

CameraOpts are the optional parameters of NewCamera.

Flutter: no counterpart

type CameraPose

type CameraPose struct {
	// Target is the point that the camera looks at and orbits.
	Target vecmath.Vec3
	// Distance is the distance from the eye to Target.
	Distance float64
	// Orientation turns the camera's axes into the world's: it looks along Orientation*(0, 0, -1), and its up is
	// Orientation*(0, 1, 0).
	Orientation vecmath.Quat
}

CameraPose is where a camera looks from: the point it orbits, how far it is from it and how it is turned.

Flutter: no counterpart

type DirectionalLight

type DirectionalLight struct {
	// Direction points from the scene to the light, in the world's coordinates; it need not have length 1.
	Direction vecmath.Vec3
	// Color is the color of the light; the zero value stands for white.
	Color ui.Color
	// Intensity multiplies the color; the default is 1.
	Intensity float64
}

DirectionalLight is a light that shines from one direction onto the whole scene.

Flutter: no counterpart

type DisplayMode

type DisplayMode int

DisplayMode is how the meshes of triangles of a scene are drawn (SPEC §27.8).

Flutter: no counterpart

const (
	// DisplayModeUnspecified is the zero value: shaded.
	DisplayModeUnspecified DisplayMode = iota
	// DisplayModeShaded draws the faces with their materials.
	DisplayModeShaded
	// DisplayModeShadedWithEdges draws the faces and, over them, the feature edges (FeatureEdges, in the scene's edge style).
	DisplayModeShadedWithEdges
	// DisplayModeWireframe draws every edge of the triangles as a line and no faces; nothing hides anything.
	DisplayModeWireframe
	// DisplayModeHiddenLine draws the feature edges that a face does not hide, the faces being drawn in the background color.
	DisplayModeHiddenLine
)

func (DisplayMode) String

func (m DisplayMode) String() string

String names the mode.

Flutter: no counterpart

type Environment

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

Environment is the light that comes from all around a scene, for the image-based lighting of PBRMaterial (SPEC §28.5): a cube map of the sky. The renderer prefilters it with compute passes, once, into a cube of the specular reflections (one mip level for each roughness) and a cube of the diffuse irradiance. A scene with no Environment has the neutral studio that the renderer makes itself (a gradient, a large soft box and a fill light).

Flutter: no counterpart

func NewEnvironment

func NewEnvironment(cube *gpu.Texture) *Environment

NewEnvironment makes an environment of a cube map: a texture of the kind gpu.TextureKindCube with the usage gpu.TextureUsageTextureBinding, in the format RGBA16Float (linear radiance, which may be above 1) or RGBA8Unorm (sRGB colors). Mip levels help the prefiltering (a cube with one level is filtered less well). The environment does not own the texture and the texture must live as long as a renderer may build it. It panics with TagEnvironmentInvalid for a texture that is none of these.

Flutter: no counterpart

type FitIntent

type FitIntent struct{ widgets.IntentBase }

FitIntent shows the whole scene (the camera's Bounds), with an animation.

Flutter: no counterpart

type FrameStats

type FrameStats struct {
	// Items is the number of items drawn, Culled the number that were outside the view and Hidden those that were not visible or
	// in another layer.
	Items, Culled, Hidden int
	// Draws is the number of draw calls, Batches the number of those that are batches of triangles (one draw for the items that
	// share a mesh and a material), and Instances the number of instances of triangles.
	Draws, Batches, Instances int
	// EdgeDraws is the number of draws of the edges of meshes (one for each item that has edges drawn).
	EdgeDraws int
	// CapDraws is the number of caps drawn (one for each closed item and each plane that cuts it) and OutlineDraws the number of
	// draws of the outlines of the cuts.
	CapDraws, OutlineDraws int
	// GridDraws is the number of grids drawn (0 or 1).
	GridDraws int
	// Pipelines is the number of pipelines the renderer has made.
	Pipelines int
}

FrameStats says what the last frame of a renderer did.

Flutter: no counterpart

type GridStyle

type GridStyle struct {
	// Show draws the grid; the zero value draws none.
	Show bool
	// Origin is a point of the grid's plane, in world coordinates in float64; the lines pass through it.
	Origin vecmath.Vec3
	// Normal is the direction that is perpendicular to the plane (it need not be a unit vector); the default is +y.
	Normal vecmath.Vec3
	// Spacing is the distance between two minor lines, in world units; the default is 1.
	Spacing float64
	// MajorEvery is how many minor lines make a major one; the default is 10.
	MajorEvery int
	// MinorColor and MajorColor are the colors of the lines; the defaults are the one of near black and near white that contrasts with
	// the background, at 18% and 40% of its opacity.
	MinorColor, MajorColor foundation.Opt[ui.Color]
	// LineWidth is the width of a minor line in logical pixels (a major line is twice as wide); the default is 1.
	LineWidth float64
	// FadeDistance is the distance from the eye at which the lines are gone, in world units; they start to fade at 40% of it. The
	// default is 200 times the spacing. An orthographic view has no fade.
	FadeDistance float64
}

GridStyle is the infinite grid of a scene (SceneStyle.Grid; SPEC §27.8, "Overlays"): thin minor lines and thicker major ones on a plane, which fade away with the distance and where they come closer than a few pixels. The grid is drawn over the opaque faces and under the transparent ones, tested against their depth, and is cut by the section planes. It is not picked.

Flutter: no counterpart

type Item

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

Item is one thing a scene draws: a mesh with a material, a transform in float64, a visibility, a pick ID and a layer mask (SPEC §27.8). Create it with NewItem, add it to a scene, and change it with its setters: every change draws the scene's views again.

Flutter: no counterpart

func NewItem

func NewItem(mesh *Mesh, material Material, opts ...ItemOpts) *Item

NewItem creates an item that draws the mesh with the material. A mesh of triangles takes an UnlitMaterial, a PhongMaterial or a PBRMaterial, a mesh of lines a LineMaterial and a mesh of points a PointMaterial.

Flutter: no counterpart

func (*Item) Bounds

func (it *Item) Bounds() vecmath.Box3

Bounds is the box of the item in the world, in float64: the mesh's bounds under the item's transform.

Flutter: no counterpart

func (*Item) Layers

func (it *Item) Layers() uint32

Layers is the item's layer mask.

Flutter: no counterpart

func (*Item) Material

func (it *Item) Material() Material

Material is the item's material.

Flutter: no counterpart

func (*Item) Mesh

func (it *Item) Mesh() *Mesh

Mesh is the item's mesh.

Flutter: no counterpart

func (*Item) MorphWeights

func (it *Item) MorphWeights() []float32

MorphWeights are the weights of the mesh's morph targets for this item (a copy), or nil for all 0.

Flutter: no counterpart

func (*Item) PickID

func (it *Item) PickID() uint32

PickID is the number that picking reports for the item.

Flutter: no counterpart

func (*Item) Selected

func (it *Item) Selected() bool

Selected says whether the item is selected: drawn with the highlight color and an outline (SceneStyle.Selection).

Flutter: no counterpart

func (*Item) SetLayers

func (it *Item) SetLayers(l uint32)

SetLayers changes the layer mask; 0 stands for all layers.

Flutter: no counterpart

func (*Item) SetMaterial

func (it *Item) SetMaterial(m Material)

SetMaterial changes the material.

Flutter: no counterpart

func (*Item) SetMesh

func (it *Item) SetMesh(m *Mesh)

SetMesh changes the mesh (of the same primitive as the material).

Flutter: no counterpart

func (*Item) SetMorphWeights

func (it *Item) SetMorphWeights(w []float32)

SetMorphWeights sets the weight of each morph target of the mesh, from the first; missing weights are 0 and extra ones are ignored.

Flutter: no counterpart

func (*Item) SetPickID

func (it *Item) SetPickID(id uint32)

SetPickID changes the pick ID.

Flutter: no counterpart

func (*Item) SetSelected

func (it *Item) SetSelected(on bool)

SetSelected selects or deselects the item.

Flutter: no counterpart

func (*Item) SetSkin

func (it *Item) SetSkin(s *Skin)

SetSkin gives the item a skeleton, or none (nil). The mesh must have Joints and Weights to be skinned, and its joints must be below the skin's JointCount. The items of one skin are drawn again whenever the skin changes.

Flutter: no counterpart

func (*Item) SetTransform

func (it *Item) SetTransform(t vecmath.Mat4)

SetTransform changes the transform, in float64.

Flutter: no counterpart

func (*Item) SetVisible

func (it *Item) SetVisible(v bool)

SetVisible shows or hides the item.

Flutter: no counterpart

func (*Item) Skin

func (it *Item) Skin() *Skin

Skin is the skeleton that moves the vertices of the item's mesh, or nil.

Flutter: no counterpart

func (*Item) Transform

func (it *Item) Transform() vecmath.Mat4

Transform is the item's transform in the world.

Flutter: no counterpart

func (*Item) Visible

func (it *Item) Visible() bool

Visible says whether the item is drawn.

Flutter: no counterpart

type ItemOpts

type ItemOpts struct {
	// Transform is the item's transform in the world, in float64; the default is the identity.
	Transform foundation.Opt[vecmath.Mat4]
	// Hidden makes the item invisible.
	Hidden bool
	// PickID is the number that picking reports for the item (SPEC §27.8); 0 is "nothing".
	PickID uint32
	// Layers is a bit mask of the layers the item is in; the default (0) is all of them.
	Layers uint32
}

ItemOpts are the optional parameters of NewItem.

Flutter: no counterpart

type LineMaterial

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

LineMaterial draws a mesh of lines as anti-aliased lines of a width in logical pixels, with an optional dash pattern (SPEC §27.8). The lines are expanded into quads by the vertex shader, so the width does not change with the distance.

Flutter: no counterpart

func NewLineMaterial

func NewLineMaterial(opts ...LineOpts) *LineMaterial

NewLineMaterial creates a line material.

Flutter: no counterpart

func (*LineMaterial) Color

func (m *LineMaterial) Color() ui.Color

Color is the color of the lines.

Flutter: no counterpart

func (*LineMaterial) Release

func (c *LineMaterial) Release()

Release frees the GPU resources that renderers hold of the material.

Flutter: no counterpart

func (*LineMaterial) SetColor

func (m *LineMaterial) SetColor(c ui.Color)

SetColor changes the color.

Flutter: no counterpart

func (*LineMaterial) SetStipple

func (m *LineMaterial) SetStipple(p []float64)

SetStipple changes the dash pattern; nil makes the lines solid.

Flutter: no counterpart

func (*LineMaterial) SetWidth

func (m *LineMaterial) SetWidth(w float64)

SetWidth changes the width (above 0).

Flutter: no counterpart

func (*LineMaterial) Width

func (m *LineMaterial) Width() float64

Width is the width of the lines in logical pixels.

Flutter: no counterpart

type LineOpts

type LineOpts struct {
	// Color is the color; the zero value stands for the default, near black.
	Color ui.Color
	// Width is the width in logical pixels; the default is 1.
	Width float64
	// Stipple is a dash pattern in logical pixels: a dash, a gap, a dash, a gap, ... (up to 8 lengths; an odd number repeats
	// the pattern with the roles swapped, as in SVG). The default is a solid line. The pattern runs along a polyline as the
	// segments of the mesh share ends, measured in the screen's pixels at the first end of each segment.
	Stipple []float64
}

LineOpts are the optional parameters of NewLineMaterial.

Flutter: no counterpart

type Material

type Material interface {
	foundation.Listenable
	// Release frees what the material holds on the GPU, in every renderer that drew it; a renderer makes it again if an item
	// still uses the material.
	Release()
	// contains filtered or unexported methods
}

Material says how the items that use it are drawn (SPEC §27.8). It is one of the types of this package: UnlitMaterial and PhongMaterial for meshes of triangles, LineMaterial for meshes of lines and PointMaterial for meshes of points. A material is shared by its items, and changing it (its setters) draws every view of a scene that uses it again.

Flutter: no counterpart

type Mesh

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

Mesh is geometry that is uploaded to the GPU once and shared by its items (SPEC §27.8). Its CPU data stays, so that the mesh can be uploaded again after a device is lost and its edges can be made. A mesh is used on the UI thread.

Flutter: no counterpart

func FeatureEdges

func FeatureEdges(m *Mesh, angle float64) (*Mesh, error)

FeatureEdges makes the edges that show the shape of a triangle mesh: the boundary edges (one triangle), the edges that more than two triangles share, and the edges where the angle between the normals of the two triangles is more than angle, in radians. Vertices at the same position count as one, so a mesh whose faces do not share vertices has its edges where they meet. The result is a mesh of line segments that uses the positions of m, so it costs the indices only; it is made once for each angle and kept in m (the next call with the same angle gives the same mesh), and Release of m releases it. It fails with MeshInvalid when m is not made of triangles.

Flutter: no counterpart

func NewMesh

func NewMesh(data MeshData) (*Mesh, error)

NewMesh checks the data and makes a mesh of it. It fails with MeshInvalid when the lengths do not agree (positions that are not a multiple of 3, normals, texture coordinates or colors that are not one for each vertex, both kinds of indices, an index outside the vertices, a count of vertices or indices that the primitive does not divide by) or the data holds a number that is not finite.

Flutter: no counterpart

func (*Mesh) Bounds

func (m *Mesh) Bounds() vecmath.Box3

Bounds is the box of the vertices that are used, in float64 and with the origin added: in the mesh's own coordinates (an item's transform turns them into the world's).

Flutter: no counterpart

func (*Mesh) Closed

func (m *Mesh) Closed() bool

Closed says whether a mesh of triangles is a solid: every edge between its triangles (vertices at the same position count as one) belongs to exactly two of them. A closed mesh gets a cap where a section plane cuts it. It is worked out once and kept.

Flutter: no counterpart

func (*Mesh) Data

func (m *Mesh) Data() MeshData

Data is the data the mesh was made of, with the slices that it keeps: do not change them.

Flutter: no counterpart

func (*Mesh) IndexCount

func (m *Mesh) IndexCount() int

IndexCount is the number of indices, or of vertices when there are none: what a draw of the whole mesh takes.

Flutter: no counterpart

func (*Mesh) MorphTargetCount

func (m *Mesh) MorphTargetCount() int

MorphTargetCount is the number of morph targets.

Flutter: no counterpart

func (*Mesh) Origin

func (m *Mesh) Origin() vecmath.Vec3

Origin is the mesh's origin: the positions are relative to it.

Flutter: no counterpart

func (*Mesh) Primitive

func (m *Mesh) Primitive() Primitive

Primitive is what the mesh's vertices make.

Flutter: no counterpart

func (*Mesh) PrimitiveCount

func (m *Mesh) PrimitiveCount() int

PrimitiveCount is the number of triangles, segments or points.

Flutter: no counterpart

func (*Mesh) Release

func (m *Mesh) Release()

Release frees what the mesh holds on the GPU, in every renderer that drew it (and what its edges hold). The mesh itself stays usable: a renderer uploads it again if an item still draws it. Call it when the app is done with the mesh, as with a gpu.Buffer.

Flutter: no counterpart

func (*Mesh) Skinned

func (m *Mesh) Skinned() bool

Skinned says whether the mesh has joints and weights.

Flutter: no counterpart

func (*Mesh) VertexCount

func (m *Mesh) VertexCount() int

VertexCount is the number of vertices.

Flutter: no counterpart

type MeshData

type MeshData struct {
	// Primitive is what the vertices make; the default is triangles.
	Primitive Primitive
	// Origin is the mesh's origin in float64: the positions are float32 numbers relative to it (SPEC §27.8, D30). A part
	// that is made 50 km from the world's origin keeps its precision by having its origin there and small positions.
	Origin vecmath.Vec3
	// Positions are x, y and z for each vertex, relative to Origin.
	Positions []float32
	// Normals are x, y and z for each vertex, of length 1; optional. Without them a lit material shades each face flat.
	Normals []float32
	// TexCoords are u and v for each vertex; optional.
	TexCoords []float32
	// Colors are red, green, blue and alpha (not premultiplied) for each vertex; optional. A material that uses vertex
	// colors multiplies its color by them.
	Colors []byte
	// Indices16 or Indices32 index the vertices; at most one of them is set. Without indices the vertices are taken in order.
	Indices16 []uint16
	Indices32 []uint32

	// Tangents are x, y, z and w for each vertex: the direction of the u axis of the texture, and the sign (1 or -1) of the
	// bitangent; optional. Without them a normal texture takes its frame from the derivatives of the position and the texture
	// coordinates.
	Tangents []float32
	// TexCoords1 are the second set of u and v for each vertex; optional.
	TexCoords1 []float32
	// Joints are the four joints that move each vertex, as positions in the Skin of the item, and Weights their four weights
	// (which add up to 1); both optional, and together (a mesh with them is skinned when its item has a Skin).
	Joints  []uint16
	Weights []float32
	// MorphTargets are the shapes that the mesh moves towards, added to its vertices with the weights of the item
	// (Item.SetMorphWeights); optional.
	MorphTargets []MorphTarget
}

MeshData is what NewMesh makes a mesh of. The mesh keeps the slices: do not change them afterwards.

Flutter: no counterpart

type MorphTarget

type MorphTarget struct {
	// Positions are the changes of x, y and z of each vertex, or nil for none.
	Positions []float32
	// Normals are the changes of the normal of each vertex, or nil for none.
	Normals []float32
}

MorphTarget is one morph target of a mesh: the change of each vertex at a weight of 1.

Flutter: no counterpart

type Navigation struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Navigation is the widget that lets a user move a Camera: it recognizes the drags, the wheel, the pinch, the double click and the keys of NavigationOpts, which are gesture recognizers of the gesture arena (SPEC §27.8). It is made around the view that shows the camera's picture; it sets the camera's viewport size from its own.

Flutter: no counterpart

func NewNavigation

func NewNavigation(camera *Camera, child widgets.Widget, opts ...NavigationOpts) *Navigation

NewNavigation creates a navigation of the camera around the child.

Flutter: no counterpart

func (n *Navigation) Camera() *Camera

Camera is the camera that the navigation moves.

Flutter: no counterpart

func (n *Navigation) CreateState() widgets.State

CreateState creates the state of the navigation.

Flutter: no counterpart

type NavigationAction int

NavigationAction is what an input does to the camera.

Flutter: no counterpart

const (
	// NavigationActionUnspecified is the zero value: the default of the binding (SPEC §27.8).
	NavigationActionUnspecified NavigationAction = iota
	// NavigationActionNone turns the binding off: the input does nothing here, and a recognizer that only it needed is
	// left out of the arena.
	NavigationActionNone
	// NavigationActionOrbit turns the camera around the point under the pointer, or the target.
	NavigationActionOrbit
	// NavigationActionPan moves the camera across the view.
	NavigationActionPan
	// NavigationActionZoom moves the camera towards or away from what is under the pointer.
	NavigationActionZoom
	// NavigationActionFit shows the whole scene.
	NavigationActionFit
)
type NavigationDisable int

NavigationDisable are bits that turn off the parts of the navigation that have no action of their own.

Flutter: no counterpart

const (
	// NavigationDisablePinch turns off the zoom of two fingers.
	NavigationDisablePinch NavigationDisable = 1 << iota
	// NavigationDisableTwist turns off the roll of two fingers that turn.
	NavigationDisableTwist
	// NavigationDisableTwoFingerPan turns off the pan of two fingers that move together.
	NavigationDisableTwoFingerPan
	// NavigationDisableTrackpad turns off the pinch of a trackpad.
	NavigationDisableTrackpad
	// NavigationDisableKeyboard leaves out the default keys (the arrows, plus and minus); NavigationOpts.Shortcuts still
	// works.
	NavigationDisableKeyboard
)
type NavigationOpts struct {
	// LeftDrag is what a drag of the left mouse button does; the default is NavigationActionOrbit.
	LeftDrag NavigationAction
	// ShiftLeftDrag is what a drag of the left button does while Shift is down; the default is NavigationActionPan.
	ShiftLeftDrag NavigationAction
	// MiddleDrag is what a drag of the middle button does; the default is NavigationActionPan.
	MiddleDrag NavigationAction
	// RightDrag is what a drag of the right button does; the default is NavigationActionNone.
	RightDrag NavigationAction
	// Wheel is what the mouse wheel does; the default is NavigationActionZoom, and NavigationActionNone turns it off.
	Wheel NavigationAction
	// DoubleClick is what a double click or a double tap does; the default is NavigationActionFit, and
	// NavigationActionNone turns it off.
	DoubleClick NavigationAction
	// TouchDrag is what one finger (or a stylus) does; the default is NavigationActionOrbit.
	TouchDrag NavigationAction
	// Disable turns off the parts that have no action of their own.
	Disable NavigationDisable

	// OrbitSpeed is the turn, in radians, for a logical pixel of a drag; the default is 0.01 (a drag across 600 pixels turns
	// the camera by about a third of a turn).
	OrbitSpeed float64
	// PanSpeed multiplies the pan; the default is 1, which keeps the point at the target under the pointer.
	PanSpeed float64
	// ZoomSpeed multiplies the zoom of the wheel and of a drag; the default is 1.
	ZoomSpeed float64
	// PinchSpeed multiplies the zoom of a pinch: the distance changes by the pinch's ratio to this power; the default is 1.
	PinchSpeed float64
	// InvertZoom reverses the direction of the wheel.
	InvertZoom bool
	// KeyboardOrbitStep is the turn of one press of an arrow, in radians; the default is 0.1.
	KeyboardOrbitStep float64
	// KeyboardZoomStep is the factor of one press of plus or minus; the default is 1.1 (the distance is divided by it to
	// zoom in).
	KeyboardZoomStep float64

	// LockPointer locks the pointer (SPEC §27.6) while a mouse drag orbits: the cursor is hidden and the drag does not stop
	// at the edge of the screen. A platform that cannot lock it, or refuses, gets the drag without the lock.
	LockPointer bool
	// PivotAt tells the point of the world under a point of the view, in logical pixels, or false when there is none (the
	// sky): an orbit turns around it, and the wheel zooms towards it. The view's picking gives it (SPEC §27.8); without
	// it the orbit turns around the target and the zoom keeps the point of the target's plane under the pointer.
	PivotAt func(at ui.Offset) (vecmath.Vec3, bool)

	// Shortcuts replace the default keys. The intents that the navigation handles are OrbitIntent, ZoomIntent, PanIntent,
	// FitIntent and StandardViewIntent.
	Shortcuts widgets.ShortcutMap
	// Actions are added to the navigation's actions, and replace the one of an intent they handle.
	Actions widgets.ActionMap
	// FocusNode is the focus node of the keyboard; without one the navigation makes its own. A press on the view asks for
	// the focus.
	FocusNode *widgets.FocusNode
	// Autofocus asks for the focus when the navigation is built.
	Autofocus bool
	// Duration is the length of an animated move, such as the fit of a double click; the default is 300 ms, and Some(0)
	// moves at once.
	Duration foundation.Opt[time.Duration]
	// Curve shapes an animated move; the default is animation.Curves.EaseInOut.
	Curve animation.Curve
}

NavigationOpts are the optional parameters of NewNavigation. The zero value is the default navigation of SPEC §27.8:

Mouse:    left drag orbits (around the point under the pointer, else the target), middle drag or Shift with left drag
          pans, the wheel zooms toward the pointer, a double click fits the scene
Trackpad: pinch zooms
Touch:    one finger orbits; two fingers pan, pinch and twist
Keyboard: the arrows orbit, + and - zoom

Flutter: no counterpart

type OrbitIntent

type OrbitIntent struct {
	widgets.IntentBase
	// Yaw is the number of steps counterclockwise as seen from above: the camera moves to the left when it is negative.
	Yaw float64
	// Pitch is the number of steps upwards: the camera rises when it is positive.
	Pitch float64
}

OrbitIntent turns the camera around its target by whole steps of NavigationOpts.KeyboardOrbitStep.

Flutter: no counterpart

type PBRMaterial

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

PBRMaterial draws a mesh of triangles with the physically based metallic-roughness model of glTF 2.0 (SPEC §28.5): the scene's directional lights and the light at the camera, image-based lighting from the scene's environment, one directional shadow map, and the base color, metallic-roughness, normal, occlusion and emissive textures. A scene with an item of this material is drawn in a float target and tone mapped (SceneStyle.ToneMapping). A mesh with Joints and Weights is skinned when its item has a Skin, and a mesh with morph targets follows the item's weights.

Flutter: no counterpart

func NewPBRMaterial

func NewPBRMaterial(opts ...PBROpts) *PBRMaterial

NewPBRMaterial creates a PBR material.

Flutter: no counterpart

func (*PBRMaterial) AlphaMode

func (m *PBRMaterial) AlphaMode() AlphaMode

AlphaMode is how the alpha is used.

Flutter: no counterpart

func (*PBRMaterial) Color

func (m *PBRMaterial) Color() ui.Color

Color is the base color in sRGB.

Flutter: no counterpart

func (*PBRMaterial) DoubleSided

func (m *PBRMaterial) DoubleSided() bool

DoubleSided says whether the back faces are drawn.

Flutter: no counterpart

func (*PBRMaterial) Emissive

func (m *PBRMaterial) Emissive() [3]float64

Emissive is the emitted radiance in linear units.

Flutter: no counterpart

func (*PBRMaterial) Metallic

func (m *PBRMaterial) Metallic() float64

Metallic is the metalness from 0 to 1.

Flutter: no counterpart

func (*PBRMaterial) Release

func (c *PBRMaterial) Release()

Release frees the GPU resources that renderers hold of the material.

Flutter: no counterpart

func (*PBRMaterial) Roughness

func (m *PBRMaterial) Roughness() float64

Roughness is the roughness from 0 to 1.

Flutter: no counterpart

func (*PBRMaterial) SetAlphaMode

func (m *PBRMaterial) SetAlphaMode(a AlphaMode)

SetAlphaMode changes how the alpha is used.

Flutter: no counterpart

func (*PBRMaterial) SetColor

func (m *PBRMaterial) SetColor(c ui.Color)

SetColor changes the base color.

Flutter: no counterpart

func (*PBRMaterial) SetDoubleSided

func (m *PBRMaterial) SetDoubleSided(on bool)

SetDoubleSided changes whether the back faces are drawn.

Flutter: no counterpart

func (*PBRMaterial) SetEmissive

func (m *PBRMaterial) SetEmissive(e [3]float64)

SetEmissive changes the emitted radiance.

Flutter: no counterpart

func (*PBRMaterial) SetMetallic

func (m *PBRMaterial) SetMetallic(v float64)

SetMetallic changes the metalness.

Flutter: no counterpart

func (*PBRMaterial) SetRoughness

func (m *PBRMaterial) SetRoughness(v float64)

SetRoughness changes the roughness.

Flutter: no counterpart

func (*PBRMaterial) SetTexture

func (m *PBRMaterial) SetTexture(slot PBRSlot, t PBRTexture)

SetTexture changes the texture of a slot; a PBRTexture with a nil Texture removes it. The material does not own the textures.

Flutter: no counterpart

func (*PBRMaterial) Texture

func (m *PBRMaterial) Texture(slot PBRSlot) PBRTexture

Texture is the texture of a slot (a PBRTexture with a nil Texture when there is none).

Flutter: no counterpart

func (*PBRMaterial) Transparent

func (m *PBRMaterial) Transparent() bool

Transparent says whether the items are drawn with blending: in AlphaModeBlend only (glTF ignores the alpha in the other modes).

Flutter: no counterpart

type PBROpts

type PBROpts struct {
	// Color is the base color in sRGB with the alpha, as for the other materials; the zero value stands for white.
	Color ui.Color
	// Metallic is 0 for a dielectric and 1 for a metal; the default is 0.
	Metallic foundation.Opt[float64]
	// Roughness is from 0 (a mirror) to 1; the default is 0.5.
	Roughness foundation.Opt[float64]
	// Emissive is the radiance that the surface gives out, red, green and blue in linear units (it may be above 1).
	Emissive [3]float64
	// The textures. A texture of the base color or the emissive color is in sRGB.
	BaseColorTexture, MetallicRoughnessTexture, NormalTexture, OcclusionTexture, EmissiveTexture PBRTexture
	// NormalScale scales the x and y of the normals of the normal texture; the default is 1.
	NormalScale foundation.Opt[float64]
	// OcclusionStrength is how much of the occlusion texture is used, from 0 to 1; the default is 1.
	OcclusionStrength foundation.Opt[float64]
	// AlphaMode is how the alpha is used; the default ignores it.
	AlphaMode AlphaMode
	// AlphaCutoff is the alpha below which AlphaModeMask draws nothing; the default is 0.5.
	AlphaCutoff foundation.Opt[float64]
	// DoubleSided draws the back faces too, lit as seen from behind.
	DoubleSided bool
	// VertexColors multiplies the color by the colors of the mesh's vertices.
	VertexColors bool
	// Unlit shows the color as it is (glTF's KHR_materials_unlit).
	Unlit bool
}

PBROpts are the optional parameters of NewPBRMaterial.

Flutter: no counterpart

type PBRSlot

type PBRSlot int

PBRSlot is the place of a texture in a PBRMaterial.

Flutter: no counterpart

const (
	// PBRSlotBaseColor multiplies the color; sRGB, with the alpha.
	PBRSlotBaseColor PBRSlot = iota
	// PBRSlotMetallicRoughness has the roughness in its green channel and the metalness in its blue one.
	PBRSlotMetallicRoughness
	// PBRSlotNormal has the normals in the tangent space of the surface.
	PBRSlotNormal
	// PBRSlotOcclusion has the occlusion in its red channel.
	PBRSlotOcclusion
	// PBRSlotEmissive multiplies the emissive color; sRGB.
	PBRSlotEmissive
)

The textures of a PBRMaterial.

type PBRTexture

type PBRTexture struct {
	// Texture is a 2D RGBA8Unorm (or RGBA16Float) texture with the usage TextureBinding; the material does not own it. The base
	// color and the emissive textures hold sRGB colors, the others hold numbers, as glTF says.
	Texture *gpu.Texture
	// Sampler says how the texture is read; nil is repeat with linear filtering.
	Sampler *gpu.Sampler
	// TexCoord is the set of texture coordinates of the mesh: 0 (MeshData.TexCoords) or 1 (MeshData.TexCoords1).
	TexCoord int
	// Transform changes the texture coordinates; nil for none.
	Transform *TextureTransform
}

PBRTexture is a texture that a PBRMaterial reads, with how: its sampler, which set of texture coordinates it takes and an optional transform of them. The zero value is no texture.

Flutter: no counterpart

type PanIntent

type PanIntent struct {
	widgets.IntentBase
	// Dx is the move to the right, in logical pixels.
	Dx float64
	// Dy is the move down, in logical pixels.
	Dy float64
}

PanIntent moves the camera across the view.

Flutter: no counterpart

type PhongMaterial

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

PhongMaterial draws a mesh of triangles with Blinn-Phong shading: a light at the camera, the scene's directional lights and its ambient term (SPEC §27.8; the CAD default). A mesh without normals is shaded flat.

Flutter: no counterpart

func NewPhongMaterial

func NewPhongMaterial(opts ...PhongOpts) *PhongMaterial

NewPhongMaterial creates a lit material.

Flutter: no counterpart

func (*PhongMaterial) Color

func (m *PhongMaterial) Color() ui.Color

Color is the color of the surface (before the texture, the vertex colors and the light).

Flutter: no counterpart

func (*PhongMaterial) DoubleSided

func (m *PhongMaterial) DoubleSided() bool

DoubleSided says whether the back faces are drawn too (lit as seen from behind). Otherwise they are culled.

Flutter: no counterpart

func (*PhongMaterial) SetColor

func (m *PhongMaterial) SetColor(c ui.Color)

SetColor changes the color.

Flutter: no counterpart

func (*PhongMaterial) SetDoubleSided

func (m *PhongMaterial) SetDoubleSided(on bool)

SetDoubleSided changes whether the back faces are drawn.

Flutter: no counterpart

func (*PhongMaterial) SetShininess

func (m *PhongMaterial) SetShininess(s float64)

SetShininess changes the exponent of the highlight (above 0).

Flutter: no counterpart

func (*PhongMaterial) SetSpecular

func (m *PhongMaterial) SetSpecular(c ui.Color)

SetSpecular changes the color of the highlight.

Flutter: no counterpart

func (*PhongMaterial) SetTexture

func (m *PhongMaterial) SetTexture(t *gpu.Texture)

SetTexture changes the texture; nil removes it. The material does not own the texture: the app releases it.

Flutter: no counterpart

func (*PhongMaterial) SetTransparent

func (m *PhongMaterial) SetTransparent(on bool)

SetTransparent changes whether the items are drawn with blending even when the color is opaque (a texture or the vertex colors may have alpha).

Flutter: no counterpart

func (*PhongMaterial) SetVertexColors

func (m *PhongMaterial) SetVertexColors(on bool)

SetVertexColors changes whether the colors of the mesh's vertices are used. A mesh without colors has white ones.

Flutter: no counterpart

func (*PhongMaterial) Shininess

func (m *PhongMaterial) Shininess() float64

Shininess is the exponent of the highlight.

Flutter: no counterpart

func (*PhongMaterial) Specular

func (m *PhongMaterial) Specular() ui.Color

Specular is the color of the highlight.

Flutter: no counterpart

func (*PhongMaterial) Texture

func (m *PhongMaterial) Texture() *gpu.Texture

Texture is the texture that the color is multiplied by, or nil. It must be a 2D RGBA8Unorm texture (or any that a filtering sampler can read) of the device that draws, with the usage TextureBinding.

Flutter: no counterpart

func (*PhongMaterial) Transparent

func (m *PhongMaterial) Transparent() bool

Transparent says whether the items are drawn with blending, back to front, after the opaque ones: set by the option, or because the color is not opaque.

Flutter: no counterpart

func (*PhongMaterial) VertexColors

func (m *PhongMaterial) VertexColors() bool

VertexColors says whether the colors of the mesh's vertices multiply the color.

Flutter: no counterpart

type PhongOpts

type PhongOpts struct {
	// Color is the color; the zero value stands for the default, a light gray.
	Color ui.Color
	// Specular is the color of the highlight; the zero value stands for a weak white.
	Specular ui.Color
	// Shininess is the exponent of the highlight; the default is 32.
	Shininess float64
	// Texture multiplies the color; optional.
	Texture *gpu.Texture
	// VertexColors multiplies the color by the mesh's vertex colors.
	VertexColors bool
	// DoubleSided draws the back faces too, lit as seen from behind.
	DoubleSided bool
	// Transparent draws the items with blending even when the color is opaque.
	Transparent bool
}

PhongOpts are the optional parameters of NewPhongMaterial.

Flutter: no counterpart

type PickOpts

type PickOpts struct {
	// Radius is how far from the point, in logical pixels, a primitive may be to be picked, so that a line of one pixel or a
	// point can be hit; the nearest to the point wins. The default is 2.
	Radius float64
}

PickOpts are the optional parameters of Pick.

Flutter: no counterpart

type PickRectResult

type PickRectResult struct {
	Items []*Item
}

PickRectResult is what is in a rectangle of the view: each item that has a pixel there that is not hidden by another item, once, in the order of the scene.

Flutter: no counterpart

type PickResult

type PickResult struct {
	// Hit is whether any item was within the radius of the point; the other fields are empty when it is not.
	Hit bool
	// Item is the item that was hit, and PickID its pick ID.
	Item   *Item
	PickID uint32
	// Primitive says whether a triangle, a segment or a point of the item's mesh was hit, and Index which one (the order of the
	// mesh's triangles, segments or points).
	Primitive Primitive
	Index     int
	// Point is the point of the world that was hit, in float64, made from the depth and the inverse matrices (so it is as exact
	// as the depth, far from the origin too), Normal the unit normal of the triangle that was hit, facing the camera (zero for a
	// segment and a point), and Depth the depth of the pixel, reversed-Z.
	Point, Normal vecmath.Vec3
	Depth         float64
	// At is the center of the pixel that was hit, in logical pixels of the view.
	At ui.Offset
}

PickResult is what is under a point of the view (SPEC §27.8).

Flutter: no counterpart

type PointMaterial

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

PointMaterial draws a mesh of points as round or square marks of a size in logical pixels (SPEC §27.8).

Flutter: no counterpart

func NewPointMaterial

func NewPointMaterial(opts ...PointOpts) *PointMaterial

NewPointMaterial creates a point material.

Flutter: no counterpart

func (*PointMaterial) Color

func (m *PointMaterial) Color() ui.Color

Color is the color of the points.

Flutter: no counterpart

func (*PointMaterial) Release

func (c *PointMaterial) Release()

Release frees the GPU resources that renderers hold of the material.

Flutter: no counterpart

func (*PointMaterial) SetColor

func (m *PointMaterial) SetColor(c ui.Color)

SetColor changes the color.

Flutter: no counterpart

func (*PointMaterial) SetShape

func (m *PointMaterial) SetShape(s PointShape)

SetShape changes the shape.

Flutter: no counterpart

func (*PointMaterial) SetSize

func (m *PointMaterial) SetSize(s float64)

SetSize changes the size (above 0).

Flutter: no counterpart

func (*PointMaterial) SetVertexColors

func (m *PointMaterial) SetVertexColors(on bool)

SetVertexColors changes whether the colors of the mesh's points are used. A mesh without colors is drawn in the color alone.

Flutter: no counterpart

func (*PointMaterial) Shape

func (m *PointMaterial) Shape() PointShape

Shape is round or square.

Flutter: no counterpart

func (*PointMaterial) Size

func (m *PointMaterial) Size() float64

Size is the size of the points in logical pixels.

Flutter: no counterpart

func (*PointMaterial) VertexColors

func (m *PointMaterial) VertexColors() bool

VertexColors says whether the colors of the mesh's points multiply the color.

Flutter: no counterpart

type PointOpts

type PointOpts struct {
	// Color is the color; the zero value stands for the default, orange.
	Color ui.Color
	// Size is the diameter or the side in logical pixels; the default is 4.
	Size float64
	// Shape is round or square; the default is round.
	Shape PointShape
	// VertexColors multiplies the color by the colors of the mesh's points (MeshData.Colors), as a scanned cloud has them; a mesh
	// without colors is drawn in the color alone.
	VertexColors bool
}

PointOpts are the optional parameters of NewPointMaterial.

Flutter: no counterpart

type PointShape

type PointShape int

PointShape is the shape of a point.

Flutter: no counterpart

const (
	// PointShapeUnspecified is the zero value: round.
	PointShapeUnspecified PointShape = iota
	// PointShapeRound draws a disc.
	PointShapeRound
	// PointShapeSquare draws a square.
	PointShapeSquare
)

type Pose

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

Pose is the local transforms and the morph weights that animations gave to nodes of a model at one time (SPEC §28.5). A part that no animation changed is not in it: the node keeps its own. Sample writes into a pose, and Uploaded.SetPose shows it. A pose is made once and reused: sampling again allocates nothing.

Flutter: no counterpart

func NewPose

func NewPose() *Pose

NewPose makes an empty pose: every node as the model has it.

Flutter: no counterpart

func (*Pose) Clear

func (p *Pose) Clear()

Clear forgets what the pose says, keeping its memory.

Flutter: no counterpart

func (*Pose) Local

func (p *Pose) Local(n *model.Node) model.TRS

Local is the local transform of a node in the pose: the translation, the rotation and the scale of the animations, and for what they did not change those of the node (the identity for a node that the file gave as a matrix).

Flutter: no counterpart

func (*Pose) Matrix

func (p *Pose) Matrix(n *model.Node) vecmath.Mat4

Matrix is the local matrix of a node in the pose: the node's own when no animation changed it.

Flutter: no counterpart

func (*Pose) Weights

func (p *Pose) Weights(n *model.Node) []float32

Weights are the morph weights that an animation gave a node, or nil.

Flutter: no counterpart

type Primitive

type Primitive int

Primitive is what a mesh's vertices make: triangles, lines or points.

Flutter: no counterpart

const (
	// PrimitiveUnspecified is the zero value: triangles.
	PrimitiveUnspecified Primitive = iota
	// PrimitiveTriangles is a list of triangles: three vertices (or three indices) for each. A triangle's front face is
	// the one whose vertices run counterclockwise.
	PrimitiveTriangles
	// PrimitiveLines is a list of line segments: two vertices (or two indices) for each. A polyline is a list of the
	// segments between its points, and a dash pattern runs on along segments that share an end.
	PrimitiveLines
	// PrimitivePoints is a list of points: one vertex for each.
	PrimitivePoints
)

func (Primitive) String

func (p Primitive) String() string

String names the primitive.

Flutter: no counterpart

type ProjectionKind

type ProjectionKind int

ProjectionKind is how a camera makes the third dimension flat.

Flutter: no counterpart

const (
	// ProjectionKindUnspecified is the zero value: a perspective projection.
	ProjectionKindUnspecified ProjectionKind = iota
	// ProjectionKindPerspective makes distant things smaller (reversed-Z, the far plane at infinity).
	ProjectionKindPerspective
	// ProjectionKindOrthographic keeps sizes whatever the distance, as a drawing does (reversed-Z).
	ProjectionKindOrthographic
)

type RayHit

type RayHit struct {
	// Item is the item that the ray met first, and Index the triangle of its mesh.
	Item  *Item
	Index int
	// T is the distance along the ray, Point the point of the world that the ray meets, and Normal the unit normal of the triangle,
	// turned to face the ray's origin.
	T      float64
	Point  vecmath.Vec3
	Normal vecmath.Vec3
}

RayHit is what Scene.Raycast finds.

Flutter: no counterpart

type Renderer

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

Renderer draws a Scene with a Camera into the targets of a gpu.ViewFrame: the meshes with instancing, the materials, the transparent items back to front and the display modes (SPEC §27.8). View uses one in a gpu.View; an app that draws into its own gpu.View (or a texture) makes its own and calls Init and Dispose from the view's OnInit and OnDispose, and Draw from its paint function. The view needs a depth target (Depth32Float) and may be multisampled. A renderer works on the UI thread.

Flutter: no counterpart

func NewRenderer

func NewRenderer(scene *Scene, camera *Camera, opts ...RendererOpts) *Renderer

NewRenderer creates a renderer of the scene as the camera sees it. It makes nothing on the GPU until Init gives it the device.

Flutter: no counterpart

func (*Renderer) Dispose

func (r *Renderer) Dispose()

Dispose releases everything the renderer holds on the GPU: pipelines, buffers, bind groups, and the GPU copies of the meshes and the materials that it drew (the meshes and the materials stay usable). Call it from gpu.ViewOpts.OnDispose. The renderer can be given a device again with Init.

Flutter: no counterpart

func (*Renderer) Draw

func (r *Renderer) Draw(f *gpu.ViewFrame)

Draw draws the scene into the targets of the frame, with the frame's encoder: a pass that clears them to the scene's background and draws the opaque faces (a batch of instances for the items that share a mesh and a material), the transparent faces back to front, the edges of the display mode, the line items and the point items. It makes the pipelines, the buffers and the GPU copies of the meshes and materials when they are first needed.

Flutter: no counterpart

func (*Renderer) Init

func (r *Renderer) Init(d *gpu.Device)

Init gives the renderer the device it draws with: call it from gpu.ViewOpts.OnInit, which runs again after a device is lost and replaced. The resources are made when they are first needed.

Flutter: no counterpart

func (*Renderer) Pick

func (r *Renderer) Pick(at ui.Offset, done func(PickResult, error), opts ...PickOpts)

Pick asks for what is under a point of the view, in logical pixels. The items are drawn with their numbers into a small target around the point, in the next frame only (never every frame), and read back; done is called, from the event loop, with the result once the GPU has finished, which is in the frame after the pick's own. An error is the read of the GPU (GPUReadFailed, a lost device) or PickUnavailable.

Flutter: no counterpart

func (*Renderer) PickRect

func (r *Renderer) PickRect(rect ui.Rect, done func(PickRectResult, error))

PickRect asks for the items that are in a rectangle of the view, in logical pixels, as Pick does: for a selection with a box.

Flutter: no counterpart

func (*Renderer) Stats

func (r *Renderer) Stats() FrameStats

Stats says what the last frame did.

Flutter: no counterpart

type RendererOpts

type RendererOpts struct {
	// Layers is the bit mask of the layers that the renderer draws: an item is drawn when its layer mask has a bit in common
	// with it. The default (0) is all of them.
	Layers uint32
}

RendererOpts are the optional parameters of NewRenderer.

Flutter: no counterpart

type Scene

type Scene struct {
	foundation.ChangeNotifier
	// contains filtered or unexported fields
}

Scene is a flat list of items that the app owns and changes (SPEC §27.8): it is not a scene graph, and an app's own tree of parts becomes items with their world transforms. A Scene is a Listenable: any change (an item added, removed or changed, a material changed, the style) notifies its listeners, and the views that draw it draw again.

Flutter: no counterpart

func NewScene

func NewScene() *Scene

NewScene creates an empty scene.

Flutter: no counterpart

func (*Scene) Add

func (s *Scene) Add(items ...*Item)

Add puts items in the scene. An item is in one scene at a time: an item that is in another scene is moved.

Flutter: no counterpart

func (*Scene) Bounds

func (s *Scene) Bounds() vecmath.Box3

Bounds is the box of the visible items in the world, in float64; empty without items.

Flutter: no counterpart

func (*Scene) Clear

func (s *Scene) Clear()

Clear takes every item out of the scene.

Flutter: no counterpart

func (*Scene) ClearSelection

func (s *Scene) ClearSelection()

ClearSelection deselects every item.

Flutter: no counterpart

func (*Scene) Items

func (s *Scene) Items() []*Item

Items are the items of the scene, in the order they were added. Do not change the slice.

Flutter: no counterpart

func (*Scene) Raycast

func (s *Scene) Raycast(ray vecmath.Ray) (RayHit, bool)

Raycast finds where a ray of the world first meets a triangle of the scene's visible items, in float64, on the CPU: a ray from Camera.Ray tells what is under a point of the view at once, with no frame and no GPU, which the navigation's pivot needs. It tests every triangle of the items that the ray meets the box of, so it is for an occasional question, not for every frame; Pick answers from the picture, with one frame's delay, in any number of triangles. What a section plane cuts away is not met.

Flutter: no counterpart

func (*Scene) Remove

func (s *Scene) Remove(items ...*Item)

Remove takes items out of the scene.

Flutter: no counterpart

func (*Scene) SectionPlanes

func (s *Scene) SectionPlanes() []vecmath.Plane

SectionPlanes are the planes that cut the scene (SPEC §27.8, "Section planes").

Flutter: no counterpart

func (*Scene) Select

func (s *Scene) Select(items ...*Item)

Select makes the items the selection: they are selected and every other item of the scene is not. An item that is not in the scene is left out.

Flutter: no counterpart

func (*Scene) Selection

func (s *Scene) Selection() []*Item

Selection returns the selected items of the scene, in the order of the scene.

Flutter: no counterpart

func (*Scene) SetSectionPlanes

func (s *Scene) SetSectionPlanes(planes ...vecmath.Plane)

SetSectionPlanes sets the planes that cut the scene, at most MaxSectionPlanes, in world coordinates in float64. A plane cuts away what is on the side its normal points to (the points where Plane.DistanceTo is positive), in the faces, the lines and the points; where the solid meshes are cut, a cap closes them and an outline marks the cut (SceneStyle.Section). A normal that is not a unit vector is made one. Each frame the planes are made relative to the eye, in float64, like the models (D30). It panics with SectionInvalid in debug builds for too many planes or a normal with no length.

Flutter: no counterpart

func (*Scene) SetStyle

func (s *Scene) SetStyle(st SceneStyle)

SetStyle changes the style.

Flutter: no counterpart

func (*Scene) Style

func (s *Scene) Style() SceneStyle

Style is the style of the scene.

Flutter: no counterpart

type SceneStyle

type SceneStyle struct {
	// Background is the color the view is cleared to; the default is a dark gray-blue. Some(ui.Color{}) is transparent.
	Background foundation.Opt[ui.Color]
	// DisplayMode is how the triangles are drawn; the default is shaded.
	DisplayMode DisplayMode
	// Ambient is the light that comes from everywhere, from 0 to 1; the default is 0.3.
	Ambient foundation.Opt[float64]
	// HeadLight is the strength of the light at the camera, from 0 to 1; the default is 0.7. The CAD default (SPEC §27.8):
	// a face that looks at the camera has its color as it is.
	HeadLight foundation.Opt[float64]
	// Lights are up to 4 directional lights, added to the light at the camera.
	Lights []DirectionalLight
	// EdgeAngle is the angle in radians over which the edge between two triangles is a feature edge; the default is 30 degrees.
	EdgeAngle foundation.Opt[float64]
	// EdgeColor is the color of the edges; the default is near black over faces, and where the edges are drawn against the
	// background (wireframe, hidden line) it is the one of the two, near black or near white, that contrasts with it.
	EdgeColor foundation.Opt[ui.Color]
	// EdgeWidth is the width of the edges in logical pixels; the default is 1.
	EdgeWidth float64
	// Section is how the cut of the section planes looks (Scene.SetSectionPlanes).
	Section SectionStyle
	// Selection is how the selected items look (Item.SetSelected).
	Selection SelectionStyle
	// Grid is the infinite grid; none by default.
	Grid GridStyle
	// Environment is the light of the sky for the PBR materials; nil is the neutral studio that the renderer makes (SPEC §28.5).
	Environment *Environment
	// EnvironmentIntensity multiplies the light of the environment; the default is 1.
	EnvironmentIntensity foundation.Opt[float64]
	// Shadow is the directional shadow map of the PBR materials.
	Shadow ShadowStyle
	// ToneMapping is the curve that turns the float image of the PBR materials into colors; the default is the Khronos PBR
	// Neutral one.
	ToneMapping ToneMapping
	// Exposure multiplies the radiance before the tone mapping; the default is 1.
	Exposure foundation.Opt[float64]
}

SceneStyle is how a scene looks, apart from its items: the background, the display mode, the light and the edges. The zero value is the default.

Flutter: no counterpart

type SectionStyle

type SectionStyle struct {
	// NoCap leaves the solid meshes open where a plane cuts them; by default a cap closes each one.
	NoCap bool
	// CapColor is the color of the caps; the default is the color of the cut item's material.
	CapColor foundation.Opt[ui.Color]
	// NoOutline leaves out the outline of the cut.
	NoOutline bool
	// OutlineColor is the color of the outline; the default is the color of the edges.
	OutlineColor foundation.Opt[ui.Color]
	// OutlineWidth is the width of the outline in logical pixels; the default is twice the width of the edges.
	OutlineWidth float64
}

SectionStyle is how a cut looks (SceneStyle.Section).

Flutter: no counterpart

type SelectionStyle

type SelectionStyle struct {
	// Color is the highlight color; the default is amber.
	Color foundation.Opt[ui.Color]
	// Tint is how much of the highlight color replaces the color of the material of a selected item, from 0 to 1; the default is
	// 0.35. Lines and points of a selected item are drawn in the highlight color.
	Tint foundation.Opt[float64]
	// OutlineWidth is the width in logical pixels of the outline around the selected items that have faces; the default is 2.
	OutlineWidth float64
	// NoOutline leaves out the outline.
	NoOutline bool
}

SelectionStyle is how the selected items look (SceneStyle.Selection).

Flutter: no counterpart

type ShadowStyle

type ShadowStyle struct {
	// Enabled draws the shadow of the light.
	Enabled bool
	// Light is the index in SceneStyle.Lights of the light that casts the shadow; the default is the first.
	Light int
	// Size is the side of the shadow map in texels, 256 to 8192; the default is 2048.
	Size int
	// Strength is how dark the shadow is, from 0 to 1; the default is 1.
	Strength foundation.Opt[float64]
}

ShadowStyle is the shadow map of the PBR materials: one directional light casts the shadows of every triangle item onto the PBR items (SPEC §28.5).

Flutter: no counterpart

type Skin

type Skin struct {
	foundation.ChangeNotifier
	// contains filtered or unexported fields
}

Skin is the skeleton of the items that use it (SPEC §28.5): for each joint, the inverse bind matrix (the joint's world transform when the mesh was bound to it, inverted) and the joint's current world transform, which the app sets each frame (Uploaded.SetPose does it for a glTF model). The mesh's joints (MeshData.Joints) number the joints of the skin. A Skin is a Listenable: setting a joint draws the views of the scenes whose items use it again.

Flutter: no counterpart

func NewSkin

func NewSkin(inverseBind []vecmath.Mat4) *Skin

NewSkin creates a skin with one joint for each inverse bind matrix. The joints are at rest: their world transforms are the inverses of the inverse bind matrices, so the skinned mesh is in its bind pose.

Flutter: no counterpart

func (*Skin) InverseBindMatrix

func (s *Skin) InverseBindMatrix(joint int) vecmath.Mat4

InverseBindMatrix is the inverse bind matrix of a joint.

Flutter: no counterpart

func (*Skin) JointCount

func (s *Skin) JointCount() int

JointCount is the number of joints.

Flutter: no counterpart

func (*Skin) JointMatrices

func (s *Skin) JointMatrices(itemTransform vecmath.Mat4, origin vecmath.Vec3, dst []vecmath.Mat4)

JointMatrices writes the matrices that the vertex shader blends, one for each joint, for an item with the transform itemTransform (the item's, before the translation to its mesh's origin) and a mesh whose origin is origin: the matrix of a joint takes a position relative to the origin, in the bind pose, to the position relative to the origin that the joint puts it at:

translation(-origin) · inverse(itemTransform) · jointWorld · inverseBind · translation(origin)

(glTF 2.0, 3.7.3.3: the item's own transform is left out of the skin, so a skinned mesh follows its joints, not its node). It is made in float64, so the matrices are small however far the item is from the origin of the world (D30). dst needs a place for each joint; a transform that cannot be inverted gives the identity matrices.

Flutter: no counterpart

func (*Skin) JointWorld

func (s *Skin) JointWorld(joint int) vecmath.Mat4

JointWorld is the current world transform of a joint.

Flutter: no counterpart

func (*Skin) SetJointWorld

func (s *Skin) SetJointWorld(joint int, m vecmath.Mat4)

SetJointWorld changes the world transform of a joint, in float64.

Flutter: no counterpart

func (*Skin) SetJoints

func (s *Skin) SetJoints(world []vecmath.Mat4)

SetJoints changes the world transforms of the first len(world) joints at once, and tells the listeners once.

Flutter: no counterpart

type StandardView

type StandardView int

StandardView is one of the views that a CAD program names: seen along an axis, or from a corner.

Flutter: no counterpart

const (
	// StandardViewUnspecified is the zero value: no view.
	StandardViewUnspecified StandardView = iota
	// StandardViewFront looks at the front of the model, from the camera's Front direction.
	StandardViewFront
	// StandardViewBack looks at the back of the model.
	StandardViewBack
	// StandardViewLeft looks at the left side of the model.
	StandardViewLeft
	// StandardViewRight looks at the right side of the model.
	StandardViewRight
	// StandardViewTop looks down on the model, from the Up direction.
	StandardViewTop
	// StandardViewBottom looks up at the model.
	StandardViewBottom
	// StandardViewIsometric looks from the corner between the front, the right and the top.
	StandardViewIsometric
)

func (StandardView) String

func (v StandardView) String() string

String names the view.

Flutter: no counterpart

type StandardViewIntent

type StandardViewIntent struct {
	widgets.IntentBase
	// View is the view to go to.
	View StandardView
}

StandardViewIntent turns the camera to a standard view, with an animation.

Flutter: no counterpart

type TextureTransform

type TextureTransform struct {
	// Offset is added to the coordinates after the rotation.
	Offset [2]float32
	// Rotation is the angle in radians, counterclockwise in the image.
	Rotation float32
	// Scale multiplies the coordinates first; the zero value stands for (1, 1).
	Scale [2]float32
}

TextureTransform is the transform of the texture coordinates of KHR_texture_transform: they are scaled, rotated and moved.

Flutter: no counterpart

type ToneMapping

type ToneMapping int

ToneMapping is the curve that turns the radiance of the PBR materials, which may be above 1, into the colors of the display (SPEC §28.5). A scene with a PBR item is drawn into an RGBA16Float target and tone mapped over the view.

Flutter: no counterpart

const (
	// ToneMappingUnspecified is the zero value: ToneMappingNeutral.
	ToneMappingUnspecified ToneMapping = iota
	// ToneMappingNeutral is the Khronos PBR Neutral tone mapper: the colors below about 0.76 keep their value, the brighter ones
	// are compressed towards white. It keeps the colors of a material as they were authored.
	ToneMappingNeutral
	// ToneMappingACES is the fit of the ACES reference rendering transform by Stephen Hill: a filmic curve with more contrast.
	ToneMappingACES
	// ToneMappingNone clips the radiance to 0 to 1.
	ToneMappingNone
)

func (ToneMapping) String

func (t ToneMapping) String() string

String names the curve.

Flutter: no counterpart

type UnlitMaterial

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

UnlitMaterial draws a mesh of triangles with its color (or texture, or vertex colors) as it is, with no light.

Flutter: no counterpart

func NewUnlitMaterial

func NewUnlitMaterial(opts ...UnlitOpts) *UnlitMaterial

NewUnlitMaterial creates a material that shows a color as it is.

Flutter: no counterpart

func (*UnlitMaterial) Color

func (m *UnlitMaterial) Color() ui.Color

Color is the color of the surface (before the texture, the vertex colors and the light).

Flutter: no counterpart

func (*UnlitMaterial) DoubleSided

func (m *UnlitMaterial) DoubleSided() bool

DoubleSided says whether the back faces are drawn too (lit as seen from behind). Otherwise they are culled.

Flutter: no counterpart

func (*UnlitMaterial) SetColor

func (m *UnlitMaterial) SetColor(c ui.Color)

SetColor changes the color.

Flutter: no counterpart

func (*UnlitMaterial) SetDoubleSided

func (m *UnlitMaterial) SetDoubleSided(on bool)

SetDoubleSided changes whether the back faces are drawn.

Flutter: no counterpart

func (*UnlitMaterial) SetTexture

func (m *UnlitMaterial) SetTexture(t *gpu.Texture)

SetTexture changes the texture; nil removes it. The material does not own the texture: the app releases it.

Flutter: no counterpart

func (*UnlitMaterial) SetTransparent

func (m *UnlitMaterial) SetTransparent(on bool)

SetTransparent changes whether the items are drawn with blending even when the color is opaque (a texture or the vertex colors may have alpha).

Flutter: no counterpart

func (*UnlitMaterial) SetVertexColors

func (m *UnlitMaterial) SetVertexColors(on bool)

SetVertexColors changes whether the colors of the mesh's vertices are used. A mesh without colors has white ones.

Flutter: no counterpart

func (*UnlitMaterial) Texture

func (m *UnlitMaterial) Texture() *gpu.Texture

Texture is the texture that the color is multiplied by, or nil. It must be a 2D RGBA8Unorm texture (or any that a filtering sampler can read) of the device that draws, with the usage TextureBinding.

Flutter: no counterpart

func (*UnlitMaterial) Transparent

func (m *UnlitMaterial) Transparent() bool

Transparent says whether the items are drawn with blending, back to front, after the opaque ones: set by the option, or because the color is not opaque.

Flutter: no counterpart

func (*UnlitMaterial) VertexColors

func (m *UnlitMaterial) VertexColors() bool

VertexColors says whether the colors of the mesh's vertices multiply the color.

Flutter: no counterpart

type UnlitOpts

type UnlitOpts struct {
	// Color is the color; the zero value stands for the default, a light gray.
	Color ui.Color
	// Texture multiplies the color; optional.
	Texture *gpu.Texture
	// VertexColors multiplies the color by the mesh's vertex colors.
	VertexColors bool
	// DoubleSided draws the back faces too.
	DoubleSided bool
	// Transparent draws the items with blending even when the color is opaque.
	Transparent bool
}

UnlitOpts are the optional parameters of NewUnlitMaterial.

Flutter: no counterpart

type UploadOpts

type UploadOpts struct {
	// FirstPickID, when it is not 0, is the PickID of the first item; the next ones have the next numbers, so that picking tells
	// which part of the model was hit (UploadedPart tells which item has which number). The default (0) gives no item a PickID.
	FirstPickID uint32
	// Layers is the layer mask of the items; the default (0) is all of them.
	Layers uint32
	// Transform is the transform of the whole model in the world, in float64 (applied after the nodes'); the default is the
	// identity. Uploaded.Bounds stays in the model's own coordinates.
	Transform foundation.Opt[vecmath.Mat4]
	// Logger gets the notes of Upload (an image that cannot be decoded); slog.Default() when nil.
	Logger *slog.Logger
}

UploadOpts are the optional parameters of Upload.

Flutter: no counterpart

type Uploaded

type Uploaded struct {
	// Parts are the items, one for each mesh of each node of the model, in the order of the tree.
	Parts []UploadedPart
	// Bounds is the box of the model in the coordinates of its top nodes.
	Bounds vecmath.Box3
	// contains filtered or unexported fields
}

Uploaded is what Upload made of a model.

Flutter: no counterpart

func Upload

func Upload(ctx context.Context, device *gpu.Device, m *model.Model, opts ...UploadOpts) (*Uploaded, error)

Upload makes the meshes, the materials and the items of a model (SPEC §27.9): a mesh of the scene for each mesh of the model, shared by the nodes that use it; a PhongMaterial (or a LineMaterial or a PointMaterial, by the primitive of the mesh) for each material, with a texture for the base color image, which is decoded here (ui.InstantiateImageCodec) and made on the device; and an item for each mesh of each node, at the product of the transforms from the top node down to it, in float64. Positions in float64 become the origin of the mesh in float64 and positions in float32 relative to it (D30). Add the items to a scene; release the result when the scene no longer shows them.

It fails with MeshInvalid for a mesh of the model that is not valid (an index outside the vertices, ...), and with the errors of the device when a texture cannot be made. An image that cannot be decoded is left out, with a line in the log.

Flutter: no counterpart

func (*Uploaded) Items

func (u *Uploaded) Items() []*Item

Items are the items of the parts, to be added to a scene.

Flutter: no counterpart

func (*Uploaded) Release

func (u *Uploaded) Release()

Release frees the meshes, the materials and the textures that Upload made. The items are not removed from their scene: do that first (Scene.Remove), as the items draw nothing without them.

Flutter: no counterpart

func (*Uploaded) SetPose

func (u *Uploaded) SetPose(p *Pose)

SetPose shows a pose (Animation.Sample) of the model: the nodes get the local transforms of the pose where it has them (the ones of the model elsewhere) and the world transforms from them, the items follow their nodes, the skeletons get the world transforms of their joints, and the items with morph targets get the weights of the pose (those of their node or their mesh where it has none). A nil pose is the model at rest. Call it each frame an animation plays; a frame that changes nothing draws nothing again.

Flutter: no counterpart

func (*Uploaded) SetTransform

func (u *Uploaded) SetTransform(t vecmath.Mat4)

SetTransform moves the whole model: t is the transform of the model in the world, which UploadOpts.Transform sets when the model is uploaded, and is applied after the nodes' (Uploaded.Bounds stays in the model's own coordinates). The items and the skeletons follow it, with the pose that SetPose last showed. A game moves a character this way, one call for each frame it moves, and then shows the pose of its animation (SetPose).

Flutter: no counterpart

type UploadedPart

type UploadedPart struct {
	// Item draws Mesh with the material of the model's mesh, at the transform of Node and its parents.
	Item *Item
	// Node and Mesh are the node and the mesh of the model that the item is made of.
	Node *model.Node
	Mesh *model.Mesh
	// contains filtered or unexported fields
}

UploadedPart is an item of an Uploaded and where it comes from.

Flutter: no counterpart

type View

type View struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

View is the widget of a 3D scene: a gpu.View that draws a Scene as a Camera sees it with a Renderer, inside a Navigation that moves the camera. It draws when the scene or the camera changes, and not otherwise, so an idle view costs no CPU. It tells the camera the scene's bounds, and the size of the view in logical pixels (through the navigation).

Flutter: no counterpart

func NewView

func NewView(scene *Scene, camera *Camera, opts ...ViewOpts) *View

NewView creates a view of the scene as the camera sees it. It panics (TagViewInvalid) in debug builds for a nil scene or camera, and for a number of samples that is not 1 or 4.

Flutter: no counterpart

func (*View) Camera

func (v *View) Camera() *Camera

Camera is the camera the view draws with.

Flutter: no counterpart

func (*View) CreateState

func (v *View) CreateState() widgets.State

CreateState creates the state of the view.

Flutter: no counterpart

func (*View) Project

func (v *View) Project(p vecmath.Vec3) (ui.Offset, bool)

Project is the point of the view, in logical pixels, where a point of the world is drawn, and false when the point is behind the camera (Camera.Project): for dimension lines and marks that a CustomPainter draws over the view.

Flutter: no counterpart

func (*View) Scene

func (v *View) Scene() *Scene

Scene is the scene the view draws.

Flutter: no counterpart

type ViewController

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

ViewController asks a View to draw and to pick (SPEC §27.8). Make one with NewViewController and pass it as ViewOpts.Controller.

Flutter: no counterpart

func NewViewController

func NewViewController() *ViewController

NewViewController creates a controller.

Flutter: no counterpart

func (*ViewController) MarkNeedsPaint

func (c *ViewController) MarkNeedsPaint()

MarkNeedsPaint asks the view to draw once more, in the next frame.

Flutter: no counterpart

func (*ViewController) Pick

func (c *ViewController) Pick(at ui.Offset, done func(PickResult, error), opts ...PickOpts)

Pick asks for what is under a point of the view, in logical pixels (Renderer.Pick): the view draws the pick in its next frame, which is scheduled if there is none, and done is called with the result from the event loop after the GPU has finished. A controller that has no view, or a view that has no GPU, calls done at once with PickUnavailable.

Flutter: no counterpart

func (*ViewController) PickRect

func (c *ViewController) PickRect(rect ui.Rect, done func(PickRectResult, error))

PickRect asks for the items that are in a rectangle of the view, in logical pixels, as Pick does: for a selection with a box.

Flutter: no counterpart

type ViewCube

type ViewCube struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

ViewCube is a cube in a corner of a view that shows how the camera is turned, and goes to a view when it is tapped (SPEC §27.8, "Overlays"): a face goes to the standard view that looks at it, an edge to the view between two faces and a corner to the view between three, with the camera's animated move (the target and the distance stay). It turns with the camera, the part under the pointer is highlighted, and each face is in the semantics tree with a label and a tap action. NewView draws one in a corner with ViewOpts.ViewCube.

Flutter: no counterpart

func NewViewCube

func NewViewCube(camera *Camera, opts ...ViewCubeOpts) *ViewCube

NewViewCube creates the cube of a camera.

Flutter: no counterpart

func (*ViewCube) Camera

func (v *ViewCube) Camera() *Camera

Camera is the camera that the cube follows and moves.

Flutter: no counterpart

func (*ViewCube) CreateState

func (v *ViewCube) CreateState() widgets.State

CreateState creates the state of the widget.

Flutter: no counterpart

type ViewCubeOpts

type ViewCubeOpts struct {
	// Key is the key of the widget.
	Key foundation.Key
	// Size is the width and the height of the widget in logical pixels; the default is 104.
	Size float64
	// Labels are the names of the faces: front, back, right, left, top and bottom. An empty one is the default.
	Labels [6]string
	// Duration is how long the camera takes to go to a view; the default is 300 ms, and Some(0) goes at once.
	Duration foundation.Opt[time.Duration]
	// OnView is called with the direction in the world, from the model to the viewer, that a tap on the cube goes to, before the
	// camera starts to move.
	OnView func(direction vecmath.Vec3)
	// SemanticsLabel describes the cube to assistive technology; the default is "View cube".
	SemanticsLabel string
}

ViewCubeOpts are the optional parameters of NewViewCube.

Flutter: no counterpart

type ViewOpts

type ViewOpts struct {
	// Key is the key of the widget.
	Key foundation.Key
	// Samples is the number of samples of the picture's multisampling, 1 or 4; the default is 4.
	Samples int
	// Layers is the bit mask of the layers that the view draws (RendererOpts.Layers); the default is all.
	Layers uint32
	// Navigation is how the camera is moved by the pointer, the touch and the keys (NavigationOpts).
	Navigation NavigationOpts
	// NoNavigation leaves the navigation out: the view shows the camera, and the app moves it.
	NoNavigation bool
	// Continuous draws at every frame, not only when the scene or the camera changes.
	Continuous bool
	// Controller asks the view to draw once more, for a change that neither the scene nor the camera tell (a texture of a
	// material that a decoder filled, say), and to pick (ViewController.Pick).
	Controller *ViewController
	// Fallback is the widget shown when the app has no GPU; the default is an empty box.
	Fallback widgets.Widget
	// SemanticsLabel describes the view to assistive technology; the default is none.
	SemanticsLabel string
	// Children are widgets over the picture, in order: an Anchored follows a point of the world (NewAnchored), any other fills the
	// view. The pointer reaches them before the navigation.
	Children []widgets.Widget
	// Axes shows the axes of the camera in a corner (NewAxes); nil shows none. AxesAlignment is the corner, the default being the
	// bottom left.
	Axes          *AxesOpts
	AxesAlignment foundation.Opt[painting.Alignment]
	// ViewCube shows the cube that goes to the standard views (NewViewCube); nil shows none. ViewCubeAlignment is the corner, the
	// default being the top right.
	ViewCube          *ViewCubeOpts
	ViewCubeAlignment foundation.Opt[painting.Alignment]
}

ViewOpts are the optional parameters of NewView.

Flutter: no counterpart

type ZoomIntent

type ZoomIntent struct {
	widgets.IntentBase
	// In zooms in when true, out when false, by one NavigationOpts.KeyboardZoomStep.
	In bool
}

ZoomIntent moves the camera towards the target or away from it.

Flutter: no counterpart

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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