Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// Adds barycentric coordinates for each triangle vertex in a mesh.
class BarycentricFilter extends GeometryFilter {
@override
List<VertexAttrib> get generates => <VertexAttrib>[VertexAttrib('BARYCENTRIC', 3, 'float')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// Assigns a single color to every vertex in a mesh.
class ColorFilter extends GeometryFilter {
/// Creates a filter that writes [color] into the mesh `COLOR` attribute.
ColorFilter(this.color);

/// The color written to each output vertex.
Vector4 color;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// Expands a mesh to triangle vertices and generates flat-shaded normals.
class FlatShadeFilter extends GeometryFilter {
@override
List<VertexAttrib> get requires => <VertexAttrib>[VertexAttrib('POSITION', 3, 'float')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// A filter that produces a transformed copy of a [MeshGeometry].
abstract class GeometryFilter {
/// Whether this filter supports in-place modification of a mesh.
bool get inplace => false;
List<VertexAttrib> get requires => <VertexAttrib>[];
List<VertexAttrib> get generates => <VertexAttrib>[];

/// Vertex attributes that must be present on the input mesh.
List<VertexAttrib> get requires => const <VertexAttrib>[];

/// Vertex attributes that this filter guarantees on the output mesh.
List<VertexAttrib> get generates => const <VertexAttrib>[];

/// Returns a copy of the mesh with any filter transforms applied.
MeshGeometry filter(MeshGeometry mesh);
}

/// A [GeometryFilter] that can apply its transformation directly to a mesh
/// in-place.
abstract class InplaceGeometryFilter extends GeometryFilter {
@override
bool get inplace => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// Reverses triangle winding and flips normals for a mesh.
class InvertFilter extends InplaceGeometryFilter {
@override
void filterInplace(MeshGeometry mesh) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): Remove this and fix violations. See
// https://github.com/flutter/flutter/issues/186827
// ignore_for_file: public_member_api_docs

part of '../../../vector_math_geometry.dart';

/// Applies a matrix transform to each mesh position in-place.
class TransformFilter extends InplaceGeometryFilter {
/// Creates a filter that transforms positions using [transform].
TransformFilter(this.transform);

/// The transform applied to each position in the mesh.
Matrix4 transform;

@override
Expand Down