Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0-dev.2.2 #83

Merged
merged 12 commits into from
Jun 1, 2018
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ doc/api/
pubspec.lock

# Node Modules
tool/npm_template/node_modules/
node/node_modules/
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.0.0-dev.2.2

* Added `UNUSED_OBJECT` hint (#80).

* Added `KHR_texture_transform` support.

* Changed `MESH_PRIMITIVE_NO_POSITION` default severity to Warning.

## 2.0.0-dev.2.1

* Fixed a crash in the NPM build when `externalResourceFunction` isn't provided (#81).
Expand Down Expand Up @@ -72,7 +80,7 @@

## 2.0.0-dev.1.2

* Updated JS API. See [README.md](tool/npm_template/README.md) for details.
* Updated JS API. See [README.md](node/README.md) for details.

* Added external resources support for drag-n-drop web frontend.

Expand Down
3 changes: 2 additions & 1 deletion ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
|MESH_PRIMITIVE_INDEXED_SEMANTIC_CONTINUITY|Indices for indexed attribute semantic '`%1`' must start with 0 and be continuous.|Error|
|MESH_PRIMITIVE_INVALID_ATTRIBUTE|Invalid attribute name '`%1`'.|Error|
|MESH_PRIMITIVE_JOINTS_WEIGHTS_MISMATCH|Number of JOINTS attribute semantics must match number of WEIGHTS.|Error|
|MESH_PRIMITIVE_NO_POSITION|No POSITION attribute found.|Error|
|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|
Expand Down Expand Up @@ -102,6 +102,7 @@
|UNEXPECTED_EXTENSION_OBJECT|Unexpected location for this extension.|Error|
|UNRESOLVED_REFERENCE|Unresolved reference: `%1`.|Error|
|UNSUPPORTED_EXTENSION|Unsupported extension encountered: '`%1`'.|Warning|
|UNUSED_OBJECT|This object may be unused.|Hint|
## DataError
| Code | Message | Severity |
|------|---------|----------|
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ You can use hosted [web front-end tool](http://github.khronos.org/glTF-Validator
#### Installing from source code

##### Prerequisites
1. Download and install [Dart SDK](https://www.dartlang.org/install) for your platform.
2. Add Dart SDK `bin` folder to your PATH (more info [here](https://www.dartlang.org/tools/pub/installing)).
1. Download and install [Dart SDK](https://www.dartlang.org/tools/sdk/archive#dev-channel) for your platform.
2. Add Dart SDK `bin` folder to your PATH.
3. Add packages `bin` folder to your PATH (`~/.pub-cache/bin` for Linux and Mac; `%APPDATA%\Pub\Cache\bin` for Windows).

##### glTF-Validator
Expand Down Expand Up @@ -80,35 +80,45 @@ Shell return code will be non-zero if at least one error was found.

## Building

### Drag-n-Drop Web Tool
To build a drag-n-drop online validation tool (as hosted [here](http://github.khronos.org/glTF-Validator/)), follow these steps after installation:
1. Run `pub run grinder web`.
2. All needed files will be written to `build/web` directory.

### Dart Snapshot
To build application snapshot for more convenient deployment, follow these steps after installation:
To build a source snapshot for more convenient deployment, follow these steps after installation:
1. Run `pub run grinder snapshot`.
2. Snapshot will be written to `build/gltf_validator.snapshot`.
2. Snapshot will be written to `build/bin/gltf_validator.snapshot`.

It may be used like this:
```
$ dart gltf_validator.snapshot -r -p -a ./path_to_models/
```
Note, that you have to use the same Dart SDK version for building and running the snapshot. For deployment, you will need only two files: application snapshot and `dart` executable.
Note, that you have to use the same Dart SDK version for building and running the snapshot. For deployment, you will need only two files: the snapshot and `dart` executable.

You may opt to build an application snapshot for better start-up time.
Keep in mind that application snapshots are CPU architecture and operating system specific so a snapshot created, e.g., on a IA32 Linux VM cannot run on an x64 macOS VM.
To build an application snapshot, follow these steps after installation:
1. Run `pub run grinder snapshot-app`.
2. Snapshot will be written to `build/bin/gltf_validator.snapshot`.

### NPM Package
To build an npm package for use in Node.js environment, follow these steps after installation:
1. Run `pub run grinder npm`.
2. `gltf-validator` npm package will be written to `build/npm`.
2. `gltf-validator` npm package will be written to `build/node`.

Refer to the [npm package documentation](https://www.npmjs.com/package/gltf-validator) for additional information.

#### Publishing
To publish an npm package, follow these steps after installation:
1. Run `pub run grinder npm-publish`.
2. `gltf-validator` npm package will be built to `build/npm` and published to npm registry using `npm publish`.
2. `gltf-validator` npm package will be built to `build/node` and published to npm registry using `npm publish`.

### Validation Issues List
To generate [ISSUES.md](ISSUES.md), follow these steps after installation:
1. Run `pub run grinder issues`.
2. `ISSUES.md` file will be written to the repo root.

## Known Issues

- Web version can't differentiate between JSON integers and floats of the same value, e.g., `1` vs `1.0`.
- Web and npm versions cannot differentiate between JSON integers and floats of the same value, e.g., `1` vs `1.0`.
- JSON charset encoding restrictions are not enforced.
8 changes: 7 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ linter:
- avoid_catches_without_on_clauses
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_double_and_int_checks
- avoid_empty_else
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_null_checks_in_equality_operators
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
Expand Down Expand Up @@ -84,10 +87,12 @@ linter:
- prefer_final_locals
- prefer_foreach
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_initializing_formals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType
- prefer_single_quotes
- prefer_typing_uninitialized_variables
# - public_member_api_docs
Expand Down Expand Up @@ -115,4 +120,5 @@ linter:
- use_setters_to_change_properties
- use_string_buffers
- use_to_and_as_if_applicable
- valid_regexps
- valid_regexps
- void_checks
59 changes: 59 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
targets:
$default:
sources:
- "pubspec.yaml"
- "bin/gltf_validator.dart"
- "lib/**"
- "node/gltf_validator.dart"
- "web/**"
builders:
"|version_builder":
enabled: True
"|snapshot_builder":
generate_for:
- bin/**.dart
release_options:
# Keep this under release_options until https://github.com/dart-lang/build/issues/1127
snapshot_kind: app-jit
build_node_compilers|entrypoint:
generate_for:
- node/**.dart
options:
compiler: dart2js
release_options:
dart2js_args:
- --minify
- --trust-primitives
- --trust-type-annotations
dev_options:
dart2js_args:
- -DGLTF_VALIDATOR_DEBUG=true
build_web_compilers|entrypoint:
generate_for:
- web/**.dart
release_options:
compiler: dart2js
dart2js_args:
- --minify
- --no-source-maps
- --trust-primitives
- --trust-type-annotations

builders:
version_builder:
build_to: source
# See https://github.com/dart-lang/build/issues/1423
import: ../../../tool/version_builder.dart
builder_factories:
- versionBuilder
build_extensions:
"$lib$":
- gltf.g.dart
snapshot_builder:
# See https://github.com/dart-lang/build/issues/1423
import: ../../../tool/snapshot_builder.dart
builder_factories:
- snapshotBuilder
build_extensions:
".dart":
- .snapshot
11 changes: 9 additions & 2 deletions lib/cmd_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Future<void> run(List<String> args) async {
spawn();
if (--activeTasks == 0) {
watch.stop();
errPipe.write('Elapsed: ${watch.elapsedMilliseconds}ms\n');
errPipe.write('Elapsed total: ${watch.elapsedMilliseconds}ms\n');
if (foundErrors) {
exitCode = kErrorCode;
}
Expand All @@ -249,6 +249,8 @@ Future<void> run(List<String> args) async {
}

Future<bool> _processFile(ValidationTask task) async {
final watch = new Stopwatch()..start();

final file = new File(task.filename);

final opts = task.validatorOptions;
Expand All @@ -261,6 +263,7 @@ Future<bool> _processFile(ValidationTask task) async {
final ext = path.extension(task.filename).toLowerCase();
errPipe.write('Error while loading ${file.path}...\n'
'Unknown file extension `$ext`.\n');
watch.stop();
return true;
}

Expand All @@ -269,6 +272,7 @@ Future<bool> _processFile(ValidationTask task) async {
readerResult = await reader.read();
} on FileSystemException catch (e) {
errPipe.write('Error while loading ${file.path}...\n$e\n');
watch.stop();
return true;
}

Expand All @@ -281,6 +285,8 @@ Future<bool> _processFile(ValidationTask task) async {
await resourcesLoader.load();
}

watch.stop();

final reportPath = '${path.withoutExtension(task.filename)}_report.json';

// ignore: unawaited_futures
Expand All @@ -297,7 +303,8 @@ Future<bool> _processFile(ValidationTask task) async {
'Errors: ${errors.length}, '
'Warnings: ${warnings.length}, '
'Infos: ${infos.length}, '
'Hints: ${hints.length}\n\n');
'Hints: ${hints.length}\n'
'Time: ${watch.elapsedMilliseconds}ms\n\n');

if (opts.plainText) {
void writeIssues(List<Issue> issues, String title) {
Expand Down
4 changes: 3 additions & 1 deletion lib/gltf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export 'package:gltf/src/validation_result.dart';
export 'package:gltf/src/base/gltf.dart';
export 'package:gltf/src/data_access/resources_loader.dart';

const String kGltfValidatorVersion = 'GLTF_VALIDATOR_VERSION';
part 'gltf.g.dart';

const String kGltfValidatorVersion = _$gltfValidatorVersion;
4 changes: 4 additions & 0 deletions lib/gltf.g.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// AUTOGENERATED - DO NOT EDIT BY HAND
part of 'gltf.dart';

const String _$gltfValidatorVersion = '2.0.0-dev.2.2';
8 changes: 5 additions & 3 deletions lib/src/base/accessor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Accessor extends GltfChildOfRootProperty {
name: BYTE_OFFSET, args: [BUFFER_VIEW]);
}
} else {
byteOffset = getUint(map, BYTE_OFFSET, context, def: 0, min: 0);
byteOffset = getUint(map, BYTE_OFFSET, context, def: 0);
}

final componentType = getUint(map, COMPONENT_TYPE, context,
Expand Down Expand Up @@ -228,6 +228,7 @@ class Accessor extends GltfChildOfRootProperty {
context.addIssue(LinkError.unresolvedReference,
name: BUFFER_VIEW, args: [_bufferViewIndex]);
} else {
_bufferView.markAsUsed();
// Byte Stride
if (_bufferView.byteStride != -1 &&
_bufferView.byteStride < elementLength) {
Expand Down Expand Up @@ -329,6 +330,7 @@ class Accessor extends GltfChildOfRootProperty {
}

void setUsage(AccessorUsage value, String name, Context context) {
markAsUsed();
if (_usage == null) {
_usage = value;
} else if (context.validate && _usage != value) {
Expand Down Expand Up @@ -680,7 +682,7 @@ class AccessorSparseIndices extends GltfProperty {

return new AccessorSparseIndices._(
getIndex(map, BUFFER_VIEW, context, req: true),
getUint(map, BYTE_OFFSET, context, def: 0, min: 0),
getUint(map, BYTE_OFFSET, context, def: 0),
getUint(map, COMPONENT_TYPE, context,
req: true, list: gl.ELEMENT_ARRAY_TYPES),
getExtensions(map, AccessorSparseIndices, context),
Expand Down Expand Up @@ -716,7 +718,7 @@ class AccessorSparseValues extends GltfProperty {

return new AccessorSparseValues._(
getIndex(map, BUFFER_VIEW, context, req: true),
getUint(map, BYTE_OFFSET, context, def: 0, min: 0),
getUint(map, BYTE_OFFSET, context, def: 0),
getExtensions(map, AccessorSparseValues, context),
getExtras(map));
}
Expand Down
16 changes: 14 additions & 2 deletions lib/src/base/animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Animation extends GltfChildOfRootProperty {
SafeList<AnimationChannel> channels;
final channelMaps = getMapList(map, CHANNELS, context);
if (channelMaps != null) {
channels = new SafeList<AnimationChannel>(channelMaps.length);
channels = new SafeList<AnimationChannel>(channelMaps.length, CHANNELS);
context.path.add(CHANNELS);
for (var i = 0; i < channelMaps.length; i++) {
final channelMap = channelMaps[i];
Expand All @@ -54,7 +54,7 @@ class Animation extends GltfChildOfRootProperty {
SafeList<AnimationSampler> samplers;
final samplerMaps = getMapList(map, SAMPLERS, context);
if (samplerMaps != null) {
samplers = new SafeList<AnimationSampler>(samplerMaps.length);
samplers = new SafeList<AnimationSampler>(samplerMaps.length, SAMPLERS);
context.path.add(SAMPLERS);
for (var i = 0; i < samplerMaps.length; i++) {
final samplerMap = samplerMaps[i];
Expand Down Expand Up @@ -160,6 +160,7 @@ class Animation extends GltfChildOfRootProperty {
context.addIssue(LinkError.unresolvedReference,
name: NODE, args: [channel.target._nodeIndex]);
} else {
channel.target._node.markAsUsed();
switch (channel.target.path) {
case TRANSLATION:
case ROTATION:
Expand All @@ -186,6 +187,7 @@ class Animation extends GltfChildOfRootProperty {
context.addIssue(LinkError.unresolvedReference,
name: SAMPLER, args: [channel._samplerIndex]);
} else {
channel._sampler.markAsUsed();
if (channel.target != null && channel._sampler._output != null) {
if (channel.target.path == ROTATION) {
channel._sampler._output.setUnit();
Expand Down Expand Up @@ -240,6 +242,16 @@ class Animation extends GltfChildOfRootProperty {
}
});
context.path.removeLast();

if (context.validate) {
context.path.add(SAMPLERS);
for (var i = 0; i < samplers.length; ++i) {
if (!samplers[i].isUsed) {
context.addIssue(LinkError.unusedObject, index: i);
}
}
context.path.removeLast();
}
}
}

Expand Down
Loading