Component3D constructor
Component3D({
- Vector3? position,
- Vector3? scale,
- Quaternion? rotation,
- List<
Component3D> children = const [],
Component3D is a base class for any concept that lives in 3D space.
It is a Component
implementation that represents a 3D object that can be
freely moved around in 3D space, rotated, and scaled.
The main property of this class is the transform (which combines
the position
, rotation
, and scale
). Thus, the Component3D can be
seen as an object in 3D space.
It is typically not used directly, but rather use one of the following implementations:
- Object3D for a 3D object that can be bound and rendered by the GPU
- LightComponent for a light source that affects how objects are rendered
If you want to have a pure group for several components, you have two options:
- Use an Object3D, the group itself will have some superfluous render logic but should not affect your children.
- Extend the abstract class Component3D yourself.
The base Component3D class can also be used as a container for several other components. In this case, changing the position, rotating or scaling the Component3D will affect the whole group as if it was a single entity.
Implementation
Component3D({
Vector3? position,
Vector3? scale,
Quaternion? rotation,
List<Component3D> children = const [],
}) : transform = Transform3D()
..position = position ?? Vector3.zero()
..rotation = rotation ?? Quaternion.euler(0, 0, 0)
..scale = scale ?? Vector3.all(1),
super(children: children);