Skip to content

Commit

Permalink
Version 2.0.0-dev.3.3 (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lexaknyazev authored Dec 2, 2020
1 parent 898f539 commit 0768951
Show file tree
Hide file tree
Showing 79 changed files with 1,810 additions and 168 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: dart
sudo: false
dart:
- dev
- beta
- stable

dart_task:
Expand All @@ -10,7 +10,7 @@ dart_task:

matrix:
include:
- dart: dev
- dart: beta
dart_task: dartfmt

# Only building master means that we don't run two builds for each pull request.
Expand Down
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
## 2.0.0-dev.3.3

### New Features

* Added support for new PBR extensions: `KHR_materials_clearcoat`, `KHR_materials_transmission`, and `KHR_materials_sheen`.

* Added `CAMERA_YFOV_GEQUAL_PI` validation warning (#140).

* Added new `SKIN_IBM_ACCESSOR_WITH_BYTESTRIDE` error for IBM accessors using buffer views with defined `byteStride`.

* Added new `IMAGE_BUFFER_VIEW_WITH_BYTESTRIDE` error for images using buffer views with defined `byteStride`.

* Added new vendor prefixes: `ANIMECH`, `EPIC`, `GRIFFEL`, `MAXAR`, `MPEG`, `PANDA3D`, `PTC`, `SEIN`, `SPECTRUM`, `TRYON`, `UX3D`, and `VRMC`.

### Changes

* Modified `MULTIPLE_EXTENSIONS` warning. It is now reported only for explicitly standalone extensions (#145 and #146).

* Added missing check for morph target accessors overriding buffer view usage.

### Bugfixes

* Fixed an endless loop on assets with a node loop within a scene (#141).

* Fixed wrong pointer for undeclared root extensions (#150).

* Fixed building all targets at once (`pub run grinder` with no args).

* Fixed missing JS API error messages when the validator is compiled in debug mode.

* Web drag-n-drop tool now shows a correct message when no glTF assets were provided.

### Integration updates

* npm tool no longer re-defines `require` (#139).

* npm tool no longer requires `options.externalResourceFunction` for GLB or assets with embedded data (#138).

* `options.validateAccessorData` npm tool flag is removed, accessors' data validation is always enabled.

* npm tool now reports `IO_ERROR` for external resources when `options.externalResourceFunction` is not provided.

* CLI tool now supports `--stdout` flag for writing a single validation report to STDOUT instead of a new file.

* CLI tool validates binary data by default (#138).

## 2.0.0-dev.3.2

### Bugfixes
Expand Down
5 changes: 4 additions & 1 deletion ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
|BUFFER_VIEW_INVALID_BYTE_STRIDE|Only buffer views with raw vertex data can have byteStride.|Error|
|BUFFER_VIEW_TOO_BIG_BYTE_STRIDE|Buffer view's byteStride (`%1`) is greater than byteLength (`%2`).|Error|
|CAMERA_XMAG_YMAG_ZERO|xmag and ymag must not be zero.|Warning|
|CAMERA_YFOV_GEQUAL_PI|yfov should be less than Pi.|Warning|
|CAMERA_ZFAR_LEQUAL_ZNEAR|zfar must be greater than znear.|Error|
|EXTRA_PROPERTY|This property should not be defined as it will not be used.|Information|
|INTEGER_WRITTEN_AS_FLOAT|Integer value is written with fractional part: `%1`.|Warning|
Expand All @@ -52,7 +53,7 @@
|MESH_PRIMITIVE_NO_POSITION|No POSITION attribute found.|Warning|
|MESH_PRIMITIVE_TANGENT_POINTS|TANGENT attribute defined for POINTS rendering mode.|Warning|
|MESH_PRIMITIVE_TANGENT_WITHOUT_NORMAL|TANGENT attribute without NORMAL found.|Warning|
|MULTIPLE_EXTENSIONS|Multiple extensions are defined for this object: ('`%a`', '`%b`', '`%c`').|Warning|
|MULTIPLE_EXTENSIONS|This extension may be incompatible with other extensions for the object.|Warning|
|NODE_EMPTY|Empty node encountered.|Information|
|NODE_MATRIX_DEFAULT|Do not specify default transform matrix.|Information|
|NODE_MATRIX_NON_TRS|Matrix must be decomposable to TRS.|Error|
Expand Down Expand Up @@ -88,6 +89,7 @@
|BUFFER_MISSING_GLB_DATA|Buffer refers to an unresolved GLB binary chunk.|Error|
|BUFFER_VIEW_TARGET_OVERRIDE|Override of previously set bufferView target or usage. Initial: '`%1`', new: '`%2`'.|Error|
|BUFFER_VIEW_TOO_LONG|BufferView does not fit buffer (`%1`) byteLength (`%2`).|Error|
|IMAGE_BUFFER_VIEW_WITH_BYTESTRIDE|bufferView.byteStride must not be defined for buffer views containing image data.|Error|
|INVALID_IBM_ACCESSOR_COUNT|Accessor of count `%1` expected. Found `%2`.|Error|
|MESH_PRIMITIVE_ACCESSOR_UNALIGNED|Vertex attribute data must be aligned to 4-byte boundaries.|Error|
|MESH_PRIMITIVE_ACCESSOR_WITHOUT_BYTESTRIDE|bufferView.byteStride must be defined when two or more accessors use the same buffer view.|Error|
Expand All @@ -106,6 +108,7 @@
|NODE_SKIN_WITH_NON_SKINNED_MESH|Node has skin defined, but mesh has no joints data.|Error|
|NODE_WEIGHTS_INVALID|The length of weights array (`%1`) does not match the number of morph targets (`%2`).|Error|
|SCENE_NON_ROOT_NODE|Node `%1` is not a root node.|Error|
|SKIN_IBM_ACCESSOR_WITH_BYTESTRIDE|bufferView.byteStride must not be defined for buffer views used by inverse bind matrices accessors.|Error|
|SKIN_IBM_INVALID_FORMAT|Invalid IBM accessor format '`%1`'. Must be one of ('`%a`', '`%b`', '`%c`'). |Error|
|TEXTURE_INVALID_IMAGE_MIME_TYPE|Invalid MIME type '`%1`' for the texture source. Valid MIME types are ('`%a`', '`%b`', '`%c`').|Error|
|UNDECLARED_EXTENSION|Extension is not declared in extensionsUsed.|Error|
Expand Down
23 changes: 21 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ linter:
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
# - always_specify_types
- always_use_package_imports
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_as
Expand All @@ -20,6 +21,7 @@ linter:
- avoid_double_and_int_checks
- avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
Expand All @@ -41,9 +43,10 @@ linter:
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_slow_async_io
- avoid_type_to_string
- avoid_types_as_parameter_names
# - avoid_types_on_closure_parameters
# - avoid_unnecessary_containers
- avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- avoid_void_async
- avoid_web_libraries_in_flutter
Expand All @@ -59,24 +62,30 @@ linter:
- curly_braces_in_flow_control_structures
- diagnostic_describe_all_properties
- directives_ordering
# - do_not_use_environment
- empty_catches
- empty_constructor_bodies
- empty_statements
- exhaustive_cases
# - file_names
# - flutter_style_todos
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
# - missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
# - no_default_cases
- no_duplicate_case_values
# - no_logic_in_create_state
- no_logic_in_create_state
- no_runtimeType_toString
- non_constant_identifier_names
- null_closures
- omit_local_variable_types
Expand Down Expand Up @@ -128,6 +137,7 @@ linter:
- provide_deprecation_message
# - public_member_api_docs
- recursive_getters
- sized_box_for_whitespace
- slash_for_doc_comments
- sort_child_properties_last
# - sort_constructors_first
Expand All @@ -146,15 +156,24 @@ linter:
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_checks
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- unsafe_html
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_is_even_rather_than_modulo
- use_key_in_widget_constructors
- use_late_for_private_fields_and_variables
- use_raw_strings
- use_rethrow_when_possible
- use_setters_to_change_properties
- use_string_buffers
Expand Down
1 change: 1 addition & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ targets:
- "node/gltf_validator.dart"
- "tool/**"
- "web/**"
- "$package$"
builders:
build_node_compilers|entrypoint:
generate_for:
Expand Down
29 changes: 25 additions & 4 deletions lib/cmd_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ValidatorOptions {
static const String kWriteTimestamp = 'write-timestamp';
static const String kAbsolutePath = 'absolute-path';
static const String kMessages = 'messages';
static const String kStdout = 'stdout';
static const String kThreads = 'threads';

static const String kConfig = 'config';
Expand All @@ -54,6 +55,7 @@ class ValidatorOptions {
final bool absolutePath;
final bool messages;
final bool printAll;
final bool stdoutReport;
final int threads;

ValidatorOptions(
Expand All @@ -62,6 +64,7 @@ class ValidatorOptions {
this.absolutePath = false,
this.messages = false,
this.printAll = false,
this.stdoutReport = false,
this.threads = 0});

factory ValidatorOptions.fromArgs(ArgResults args) => ValidatorOptions(
Expand All @@ -70,6 +73,7 @@ class ValidatorOptions {
writeTimestamp: args[kWriteTimestamp] == true,
absolutePath: args[kAbsolutePath] == true,
printAll: args[kAll] == true,
stdoutReport: args[kStdout] == true,
threads: max(int.tryParse((args[kThreads] ?? '') as String) ?? 0, 0));
}

Expand Down Expand Up @@ -164,11 +168,15 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
Future<void> run(List<String> args) async {
ArgResults argResult;
final parser = ArgParser()
..addFlag(ValidatorOptions.kStdout,
abbr: 'o',
help: 'Print JSON report to stdout instead of writing it to a file. '
'This option cannot be used with directory input.')
..addFlag(ValidatorOptions.kValidateResources,
abbr: 'r',
help: 'Validate contents of embedded and/or '
'referenced resources (buffers, images).',
defaultsTo: false)
defaultsTo: true)
..addFlag(ValidatorOptions.kWriteTimestamp,
abbr: 't',
help: 'Write UTC timestamp to the validation report.',
Expand Down Expand Up @@ -230,6 +238,13 @@ Future<void> run(List<String> args) async {

if (FileSystemEntity.isDirectorySync(input) &&
Directory(input).statSync().type == FileSystemEntityType.directory) {
if (validatorOptions.stdoutReport) {
errPipe.write('Directory input cannot be used with '
'--${ValidatorOptions.kStdout}.\n\n');
exitCode = kErrorCode;
return;
}

final threads = 0 == validatorOptions.threads
? Platform.numberOfProcessors
: validatorOptions.threads;
Expand Down Expand Up @@ -374,9 +389,15 @@ Future<bool> _processFile(ValidationTask task) async {
}
errPipe.write(sb.toString());

await File('${task.filename}.report.json').writeAsString(
const JsonEncoder.withIndent(' ').convert(validationResult.toMap()),
flush: true);
final reportString =
const JsonEncoder.withIndent(' ').convert(validationResult.toMap());

if (task.validatorOptions.stdoutReport) {
outPipe.writeln(reportString);
} else {
await File('${task.filename}.report.json')
.writeAsString(reportString, flush: true);
}

return errors.isNotEmpty;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/gltf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

library gltf;

import 'src/version.dart';
import 'package:gltf/src/version.dart';

export 'package:gltf/src/context.dart';
export 'package:gltf/src/ext/extensions.dart';
Expand Down
9 changes: 8 additions & 1 deletion lib/src/base/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

library gltf.base.camera;

import 'dart:math' as math;
import 'package:gltf/src/base/gltf_property.dart';

class Camera extends GltfChildOfRootProperty {
Expand Down Expand Up @@ -117,6 +118,12 @@ class CameraPerspective extends GltfProperty {
checkMembers(map, CAMERA_PERSPECTIVE_MEMBERS, context);
}

final yfov = getFloat(map, YFOV, context, req: true, exclMin: 0);

if (context.validate && !yfov.isNaN && yfov >= math.pi) {
context.addIssue(SemanticError.cameraYFovGequalPi);
}

final zfar = getFloat(map, ZFAR, context, exclMin: 0);
final znear = getFloat(map, ZNEAR, context, req: true, exclMin: 0);

Expand All @@ -126,7 +133,7 @@ class CameraPerspective extends GltfProperty {

return CameraPerspective._(
getFloat(map, ASPECT_RATIO, context, exclMin: 0),
getFloat(map, YFOV, context, req: true, exclMin: 0),
yfov,
zfar,
znear,
getExtensions(map, CameraPerspective, context),
Expand Down
1 change: 1 addition & 0 deletions lib/src/base/gltf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class Gltf extends GltfProperty {

final textures = toSafeList<Texture>(TEXTURES, Texture.fromMap);

resetPath();
final extensions = getExtensions(map, Gltf, context);

resetPath();
Expand Down
20 changes: 11 additions & 9 deletions lib/src/base/gltf_property.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ abstract class Linkable {
void link(Gltf gltf, Context context);
}

mixin Usable {
bool _isUsed = false;

bool get isUsed => _isUsed;

void markAsUsed() {
_isUsed = true;
}
}

// ignore: one_member_abstracts
abstract class ResourceValidatable {
void validateResources(Gltf gltf, Context context);
}

abstract class GltfProperty implements Linkable {
abstract class GltfProperty with Usable implements Linkable {
final Map<String, Object> extensions;
final Object extras;

bool _isUsed = false;

GltfProperty(this.extensions, this.extras);

bool get isUsed => _isUsed;

void markAsUsed() {
_isUsed = true;
}

@override
void link(Gltf gltf, Context context) {}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/base/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class Image extends GltfChildOfRootProperty {
name: BUFFER_VIEW, args: [_bufferViewIndex]);
} else {
_bufferView.setUsage(BufferViewUsage.Image, BUFFER_VIEW, context);
if (_bufferView.byteStride != -1) {
context.addIssue(LinkError.imageBufferViewWithByteStride,
name: BUFFER_VIEW);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/base/material.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class Material extends GltfChildOfRootProperty {

final doubleSided = getBool(map, DOUBLE_SIDED, context);

final extensions =
getExtensions(map, Material, context, warnOnMultipleExtensions: true);
final extensions = getExtensions(map, Material, context);

final material = Material._(
pbrMetallicRoughness,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/base/mesh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ class MeshPrimitive extends GltfProperty {
if (context.validate) {
accessor.setUsage(
AccessorUsage.VertexAttribute, semantic, context);
accessor.bufferView
?.setUsage(BufferViewUsage.VertexBuffer, semantic, context);

final baseAccessor = attributes[semantic];

Expand Down
Loading

0 comments on commit 0768951

Please sign in to comment.