Skip to content

Added onProgress, onLoad, onError callback in ModelViewer #64

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

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
08a4f55
Migrate to Null Safety and update dependencies
Jan 21, 2022
9d53b76
mend
Jan 21, 2022
75d8bae
Update README.md
omchiii Jan 21, 2022
1c843fa
Change package name
Jan 21, 2022
12728c5
Revert some changes
Jan 21, 2022
3ce5581
Update README.md
omchiii Jan 21, 2022
b075d8d
Change Readme
Jan 21, 2022
102afb1
Update version
Jan 21, 2022
aea99a6
Change gitignore file
Jan 21, 2022
f57ed8c
fix parameter not passing the source
Feb 2, 2022
6df1657
Merge pull request #1 from cmedamine/fix-html-src
omchiii Feb 2, 2022
6fb1087
New version
Feb 7, 2022
4594103
Revert changes in HTML template builder
Feb 12, 2022
37d9bd5
Release hotfix version for asset loading
Feb 12, 2022
013c792
Update README.md
omchiii Feb 12, 2022
1c669e7
Add Web support.
Foldblade Feb 14, 2022
6a0854a
Update Android related for compiling in Flutter 2.10.0-0.1.pre
Foldblade Feb 14, 2022
53ba7d8
Update README.md
Foldblade Feb 14, 2022
911f9ea
Update README.md
Foldblade Feb 14, 2022
dae1388
Clean up code.
Foldblade Feb 14, 2022
03eb75a
model-viewer.js -> model-viewer.min.js v1.10.1
Foldblade Feb 16, 2022
44ab0e4
Merge pull request #4 from Foldblade/master
omchiii Feb 17, 2022
f95610c
Improve the score on pub.dev
Foldblade Feb 17, 2022
2dfd0a3
Merge pull request #6 from Foldblade/master
Foldblade Feb 17, 2022
62aba9d
For #12 - background to Colors.transparent
Foldblade Mar 13, 2022
6b4bb1f
Fix #10 , update model_viewer_plus_mobile.dart
Foldblade Mar 13, 2022
9090cc2
Update CHANGELOG.md
Foldblade Mar 14, 2022
589b6e2
Merge branch 'omchiii:master' into master
Foldblade Mar 14, 2022
eba82e3
Merge pull request #14 from Foldblade/master
omchiii Mar 14, 2022
230184c
Fix #9
Foldblade Mar 14, 2022
6f83395
Merge pull request #15 from Foldblade/master
Foldblade Mar 14, 2022
bc65c0d
Fix #11
Foldblade Mar 15, 2022
7974cd6
A less elegant solution of #8
Foldblade Mar 15, 2022
164c02b
Merge pull request #16 from Foldblade/master
omchiii Mar 17, 2022
25bf269
implementation animation-name & animation-crossfade-duration
antoinech Apr 8, 2022
c7a1204
Merge pull request #19 from antoinech/fix-missing-animation-fields
omchiii Apr 10, 2022
1d4bce6
Implement all the attributes of `<model-viewer>` v1.11.1
Foldblade Apr 26, 2022
6ecc434
Merge pull request #22 from Foldblade/master
omchiii Apr 30, 2022
84206b1
Fix #25, #29
Foldblade Jun 22, 2022
c22639d
Merge pull request #31 from Foldblade/master
omchiii Jun 24, 2022
5af0bcf
Upgrade dependencies, maybe related with #34
Foldblade Aug 4, 2022
53e56a0
Merge pull request #35 from Foldblade/master
omchiii Aug 8, 2022
101b7e4
Update html_builder.dart, Fix #40
Foldblade Sep 14, 2022
16bec82
Merge pull request #41 from Foldblade/master
omchiii Sep 15, 2022
7136591
Fix: `Removing disallowed element <SCRIPT> from [object DocumentFragm…
Foldblade Sep 18, 2022
ca36305
Merge pull request #45 from Foldblade/master
omchiii Sep 18, 2022
98aa164
[web] Add button with hotspot attributes to allowed elements
MichaelOrpheo Oct 5, 2022
14c6068
Merge pull request #49 from MichaelOrpheo/master
omchiii Oct 8, 2022
38bdecf
Added onProgress, onLoad, onError callback in ModelViewer
ahmadhassan-dev Oct 17, 2022
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
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
# Editor backup files
*~

# Pandoc outputs
*.html

# Dart artifacts
.dart_tool/
.packages
build/
pubspec.lock
.flutter-plugins
.flutter-plugins-dependencies
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* Arto Bendiken <[email protected]>

* Continued - Omer Bayram <[email protected]>
123 changes: 90 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,125 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.1] - 2020-08-21
## [1.3.3] - 2022-09-18

### Fixed
### Changed

- Set `android:usesCleartextTraffic="true"` for Android 9+ in the example
app to fix `net::ERR_CLEARTEXT_NOT_PERMITTED`. ([#7])
- Improved the reliability of the `localhost` HTTP proxy.
- Fix: `Removing disallowed element <SCRIPT> from [object DocumentFragment]`, in `lib\src\model_viewer_plus_web.dart`
- Update `example\lib\loading\display_poster.dart`
- Update `README.md`, due to `<model-viewer>` upgrades to 2.0.0 and we have not keep up with it's latest version. So, Flutter Web users should replace `src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"` with `src="./assets/packages/model_viewer_plus/assets/model-viewer.min.js"` to use the js file in our package.

### Added

- Documented `android:usesCleartextTraffic="true"` in the README. ([#7])
- Add a new example: `example\lib\loading\render_scale.dart`

## [1.3.2] - 2022-09-14

### Changed

- Update `html_builder.dart`:
- Fix `min-camera-orbit`, `max-field-of-view`, `min-field-of-view`

## [1.3.1] - 2022-08-04

### Changed

- Defaulted the background color to white when not specified. ([#7])
- Upgrade `pubspec.yaml`:
- `webview_flutter: ^3.0.1` -> `webview_flutter: ^3.0.4`
- `url_launcher: ^6.1.0` -> `url_launcher: ^6.1.5`

## [0.8.0] - 2020-08-20
## [1.3.0]~~[1.2.1]~~ - 2022-06-22

### Changed

- Required [flutter_android](https://pub.dev/packages/flutter_android)
0.8.0+.
- `README.md`: `import 'package:model_viewer_plus/model_viewer.dart';` -> `import 'package:model_viewer_plus/model_viewer_plus.dart';`
- `lib\html_builder.dart`: fix typos and uncomment `debugPrint` for more debug info
- `lib\model_viewer_plus_mobile.dart`: uncomment `debugPrint` for more debug info
- `lib\model_viewer_plus_web.dart`: unique viewType to fix [#29](https://github.com/omchiii/model_viewer_plus.dart/issues/29)
- Update `assets/model-viewer.min.js` to v1.20.0

## [1.2.0] - 2022-04-26

### Added

- Support for loading bundled asset files.
- Support for loading local files from `file://` URLs.
- Implemented a `localhost` HTTP server and proxy.
- More examples in `example/lib`

### Changed

- `lib\html_builder.dart`, `lib\model_viewer_plus_mobile.dart`, `lib\model_viewer_plus_web.dart`, `lib\model_viewer_plus.dart`: implement all the attributes of `<model-viewer>` v1.11.1.
- ModelViewer.arSacle from `final String? arScale` to `final ArScale? arScale`, which may be a breaking change.
- Update `assets/model-viewer.min.js` to v1.11.1
- Update example dir's gradle version to 7.0.2

## [1.1.5] - 2022-03-15

### Changed

- `lib/src/model_viewer_plus_mobile.dart`
- Fix [#11](https://github.com/omchiii/model_viewer_plus.dart/issues/11), add `gestureRecognizers`
- A less elegant solution of [#8](https://github.com/omchiii/model_viewer_plus.dart/issues/8), open usdz file by [url_launcher](https://pub.dev/packages/url_launcher) in SFSafariViewController.

## [1.1.4] - 2022-03-14

## [0.7.0] - 2020-08-18
### Changed

- `/lib/src/model_viewer_plus_mobile.dart`, update according to the [newest document](https://developers.google.com/ar/develop/scene-viewer#3d-or-ar). Fix [#9](https://github.com/omchiii/model_viewer_plus.dart/issues/9).
- Insted of `com.google.ar.core`, now we use `com.google.android.googlequicksearchbox`. This should support the widest possible range of devices.
- Mode defaults to `ar_preferred`. Scene Viewer launches in AR native mode as the entry mode. If Google Play Services for AR isn't present, Scene Viewer gracefully falls back to 3D mode as the entry mode.
- Add `arModes` to example, closer to [modelviewer.dev](https://modelviewer.dev)'s offical example.
- Update `example\android\app\build.gradle` `compileSdkVersion` to 31
- Update `android_intent_plus` to `3.1.1`
- Update `webview_flutter` to `3.0.1`

### Removed

- `/lib/src/http_proxy.dart`: empty file

## [1.1.3] - 2022-03-14

### Changed

- Required [flutter_android](https://pub.dev/packages/flutter_android)
for launching the Scene Viewer. ([#4])
- `ModelViewer`'s default `backgroundColor` from `Colors.white` to `Colors.transparent`, due to [#12](https://github.com/omchiii/model_viewer_plus.dart/issues/12)
- `proxy`'s null check fix and `setState() {}` for it, due to [#10](https://github.com/omchiii/model_viewer_plus.dart/issues/10)

- Upgraded to model-viewer.js
[1.1.0](https://github.com/google/model-viewer/releases/tag/v1.1.0).
## [1.1.2] - 2022-02-17

### Fixed
### Added

- Launching the Scene Viewer on Android now works. (Fixes [#4])
- `/lib/src/shim/` with `dart_html_fake.dart` and `dart_ui_fake.dart`. Fixing `ERROR: The name platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix.` and `INFO: Avoid using web-only libraries outside Flutter web plugin` to improve the [score on pub.dev](https://pub.dev/packages/model_viewer_plus/score).

- Improved error logging in case of loading errors.
### Changed

## [0.6.0] - 2020-08-18
- example's `/etc/assets` -> `/assets`

### Fixed
## [1.1.1] - 2022-02-17

- Escaped HTML attributes on the `<model-viewer>` web component.
### Added

## [0.5.0] - 2020-07-22
- `/assets/model-viewer.min.js` (v1.10.1, which is actually identical to v1.10.0)

### Changed

- `/etc/assets` -> `/assets`
- `example/flutter_02.png`: Updated the Screenshot.
- `README.md`: README Update.
- `lib/src/model_viewer_plus_web.dart`: Due to the change of `model-viewer.js` -> `model-viewer.min.js`
- `lib/src/model_viewer_plus_mobile.dart`: Due to the change of `model-viewer.js` -> `model-viewer.min.js`, added CircularProgressIndicator while mobile platform loading

### Removed

- `/etc/assets/model-viewer.js`: To slim the package size.

## [1.1.0] - 2022-02-15

### Added

- Frequently asked questions and answers in the README.
- Web Support
- `lib/src/model_viewer_plus_stub.dart`
- `lib/src/model_viewer_plus_mobile.dart`
- `lib/src/model_viewer_plus_web.dart`

[0.8.1]: https://github.com/drydart/model_viewer.dart/compare/0.8.0...0.8.1
[0.8.0]: https://github.com/drydart/model_viewer.dart/compare/0.7.0...0.8.0
[0.7.0]: https://github.com/drydart/model_viewer.dart/compare/0.6.0...0.7.0
[0.6.0]: https://github.com/drydart/model_viewer.dart/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/drydart/model_viewer.dart/compare/0.4.0...0.5.0
### Changed

[#4]: https://github.com/drydart/model_viewer.dart/issues/4
[#7]: https://github.com/drydart/model_viewer.dart/issues/7
- `lib/model_viewer_plus.dart`
- `lib/src/model_viewer_plus.dart`
52 changes: 41 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# 3D Model Viewer for Flutter

[![Project license](https://img.shields.io/badge/license-Public%20Domain-blue.svg)](https://unlicense.org)
[![Dart compatibility](https://img.shields.io/badge/dart-2.8%2B-blue)](https://pub.dev/packages/model_viewer)
[![Pub package](https://img.shields.io/pub/v/model_viewer.svg)](https://pub.dev/packages/model_viewer)
[![Dartdoc reference](https://img.shields.io/badge/dartdoc-reference-blue.svg)](https://pub.dev/documentation/model_viewer/latest/)
<https://pub.dev/packages/model_viewer> - Fork from a package that is discontinued,
and add the web support for it.

This is a [Flutter](https://flutter.dev) widget for rendering interactive
3D models in the [glTF](https://www.khronos.org/gltf/) and
Expand All @@ -14,23 +12,24 @@ web component in a [WebView](https://pub.dev/packages/webview_flutter).

## Screenshot

<img alt="Screenshot of astronaut model" src="https://raw.githubusercontent.com/drydart/model_viewer.dart/master/example/flutter_01.png" width="480"/>
<img alt="Screenshot of astronaut model" src="./example/flutter_01.png" width="480"/>
<img alt="Screenshot of astronaut model" src="./example/flutter_02.png" width="480"/>

## Prerequisites
## Compatibility

- [Dart](https://dart.dev) 2.8+ and [Flutter](https://flutter.dev) 1.17+
Android, iOS, Web, with [a recent system browser version](https://modelviewer.dev/#section-browser-support).

## Compatibility
## Notes

Android and iOS, with [a recent system browser version](https://modelviewer.dev/#section-browser-support).
We use the [Google APP](https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox), `com.google.android.googlequicksearchbox` to display interactive 3D models on Android. The model displays in 'ar_preferred' mode by default, Scene Viewer launches in AR native mode as the entry mode. If [Google Play Services for AR (ARCore, `com.google.ar.core`)](https://play.google.com/store/apps/details?id=com.google.ar.core) isn't present, Scene Viewer gracefully falls back to 3D mode as the entry mode.

## Installation

### `pubspec.yaml`

```yaml
dependencies:
model_viewer: ^0.8.1
model_viewer_plus: ^(newest from https://pub.dev/packages/model_viewer_plus)
```

### `AndroidManifest.xml` (Android 9+ only)
Expand Down Expand Up @@ -58,6 +57,19 @@ changed the default for [`android:usesCleartextTraffic`] from `true` to

This does not affect Android 8 and earlier. See [#7] for more information.

### `app/build.gradle` (Android only)

Change minSdkVersion to 19.

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.lab_rat"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

### `Info.plist` (iOS only)

To use this widget on iOS, you need to opt-in to the embedded views preview
Expand All @@ -69,6 +81,22 @@ the key `io.flutter.embedded_views_preview` and the value `YES`:
<true/>
```

### `web/index.html` (Web only)

Modify the `<head>` tag of your `web/index.html` to load the JavaScript, like so:

```html
<head>

<!-- Other stuff -->

<script type="module" src="./assets/packages/model_viewer_plus/assets/model-viewer.min.js" defer></script>
</head>
```

`./assets/packages/model_viewer_plus/assets/model-viewer.min.js` will use the default js file which is included in this package's asset. The [official site](https://modelviewer.dev) uses unpkg, by using `https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js`, you are using the latest version of `<model-viewier>`. You may replace the
value of `src` attribute with another CDN mirror's URL. But please notice that our model-viewer-plus maybe not able to keep up with the `<model-viewier>`'s latest version.

## Features

- Renders glTF and GLB models. (Also, [USDZ] models on iOS 12+.)
Expand All @@ -89,7 +117,7 @@ the key `io.flutter.embedded_views_preview` and the value `YES`:
### Importing the library

```dart
import 'package:model_viewer/model_viewer.dart';
import 'package:model_viewer_plus/model_viewer_plus.dart';
```

### Creating a `ModelViewer` widget
Expand Down Expand Up @@ -126,6 +154,8 @@ class MyApp extends StatelessWidget {

### Loading a model from the file system

This is not avaliable on Web.

```dart
class MyApp extends StatelessWidget {
// ...
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Quality Assurance

- `test/model_viewer_test.dart`: Implement widget tests.
- `test/model_viewer_plus_test.dart`: Implement widget tests.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1
1.3.3
1,173 changes: 1,173 additions & 0 deletions assets/model-viewer.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions assets/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body,
model-viewer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

/* other-css */
</style>
<script type="module" src="model-viewer.min.js" defer></script>
Empty file removed bin/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion doc/.gitignore

This file was deleted.

Empty file removed etc/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion etc/assets/.gitattributes

This file was deleted.

Loading