Skip to content

Commit 8a06dca

Browse files
FarazFaraz
Faraz
authored and
Faraz
committed
ready for merge
1 parent c0d87e3 commit 8a06dca

File tree

9 files changed

+53
-50
lines changed

9 files changed

+53
-50
lines changed

example/lib/main.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,19 @@ class _MyHomePageState extends State<MyHomePage> {
143143
changeModel = !changeModel;
144144
chosenAnimation = null;
145145
chosenTexture = null;
146-
if(changeModel){
146+
if (changeModel) {
147147
srcObj = 'assets/Football.obj';
148148
srcGlb = 'assets/sheen_chair.glb';
149-
}
150-
else{
149+
} else {
151150
srcObj = 'assets/flutter_dash.obj';
152151
srcGlb = 'assets/business_man.glb';
153152
}
154153
});
155154
},
156-
icon: const Icon(Icons.restore_page_outlined,size: 30,),
155+
icon: const Icon(
156+
Icons.restore_page_outlined,
157+
size: 30,
158+
),
157159
)
158160
],
159161
),

lib/src/core/exception/flutter_3d_controller_exception.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ class Flutter3dControllerException implements Exception {
1010
class Flutter3dControllerLoadingException extends Flutter3dControllerException {
1111
Flutter3dControllerLoadingException({String? message})
1212
: super(
13-
message: message ?? 'The 3D model is not loaded yet or is still loading.'
14-
' All controller functionality, such as playAnimation,'
15-
' camera controls, texture management, etc, should only be'
16-
' executed after the model has fully loaded.',
13+
message: message ??
14+
'The 3D model is not loaded yet or is still loading.'
15+
' All controller functionality, such as playAnimation,'
16+
' camera controls, texture management, etc, should only be'
17+
' executed after the model has fully loaded.',
1718
);
1819

1920
@override
2021
String toString() => 'Flutter3DControllerLoadingException: $message';
2122
}
2223

2324
class Flutter3dControllerFormatException extends Flutter3dControllerException {
24-
Flutter3dControllerFormatException({String? message}) : super(
25+
Flutter3dControllerFormatException({String? message})
26+
: super(
2527
message: message ?? 'Wrong model format has been used.',
2628
);
2729

lib/src/core/modules/model_viewer/model_viewer_mobile.dart

Lines changed: 24 additions & 24 deletions
Large diffs are not rendered by default.

lib/src/core/modules/model_viewer/model_viewer_web.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ class ModelViewerState extends State<ModelViewer> {
2525
super.dispose();
2626
}
2727

28-
2928
@override
3029
void didUpdateWidget(covariant ModelViewer oldWidget) {
3130
super.didUpdateWidget(oldWidget);
32-
if(oldWidget.src != widget.src){
31+
if (oldWidget.src != widget.src) {
3332
setState(() {
3433
_isLoading = true;
3534
});
@@ -39,7 +38,6 @@ class ModelViewerState extends State<ModelViewer> {
3938
}
4039
}
4140

42-
4341
@override
4442
Widget build(final BuildContext context) {
4543
if (_isLoading) {
@@ -67,7 +65,7 @@ class ModelViewerState extends State<ModelViewer> {
6765

6866
ui_web.platformViewRegistry.registerViewFactory(
6967
'model-viewer-html-$_uniqueViewType',
70-
(viewId) {
68+
(viewId) {
7169
// Create a DivElement to hold the content
7270
final element = html.DivElement()
7371
..style.border = 'none'

lib/src/core/modules/obj_viewer/mesh.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ Future<Image?> packingTexture(List<Mesh> meshes) async {
531531
final String key = getMeshKey(mesh);
532532
final Rect? rect = textures[key]?.textureRect;
533533
if (rect != null) mesh.textureRect = rect;
534-
}
534+
}
535535

536536
final c = Completer<Image>();
537537
decodeImageFromPixels(texture.buffer.asUint8List(), textureWidth,

lib/src/core/modules/obj_viewer/obj_viewer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class _ObjViewerState extends State<ObjViewer> {
6767
@override
6868
void didUpdateWidget(covariant ObjViewer oldWidget) {
6969
super.didUpdateWidget(oldWidget);
70-
if(oldWidget.src != widget.src){
70+
if (oldWidget.src != widget.src) {
7171
scene = Scene(
7272
onUpdate: () => setState(() {}),
7373
onObjectCreated: widget.onObjectCreated,

lib/src/core/modules/obj_viewer/scene.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ class Scene {
191191
if (colorCount != o.mesh.colors.length) {
192192
final int colorValue = (o.mesh.texture != null)
193193
? const Color.fromARGB(0, 0, 0, 0).colorValue
194-
: toColor(o.mesh.material.diffuse, o.mesh.material.opacity).colorValue;
194+
: toColor(o.mesh.material.diffuse, o.mesh.material.opacity)
195+
.colorValue;
195196
for (int i = 0; i < colorCount; i++) {
196197
renderColors[vertexOffset + i] = colorValue;
197198
}

lib/src/data/datasources/flutter_3d_datasource_mobile.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class Flutter3DDatasource implements IFlutter3DDatasource {
6161
"document.getElementById(\"$_viewerId\").availableAnimations;",
6262
);
6363
List<String> animations = [];
64-
for(final animItem in rawAnimations){
65-
if(animItem!=null){
64+
for (final animItem in rawAnimations) {
65+
if (animItem != null) {
6666
animations.add(animItem.toString());
6767
}
6868
}
@@ -83,13 +83,13 @@ class Flutter3DDatasource implements IFlutter3DDatasource {
8383

8484
@override
8585
Future<List<String>> getAvailableTextures() async {
86-
try{
86+
try {
8787
final List<Object?> rawVariants = await executeCustomJsCodeWithResult(
8888
"document.getElementById(\"$_viewerId\").availableVariants;",
8989
);
90-
List<String> variants = [];
91-
for(final variantItem in rawVariants){
92-
if(variantItem!=null){
90+
List<String> variants = [];
91+
for (final variantItem in rawVariants) {
92+
if (variantItem != null) {
9393
variants.add(variantItem.toString());
9494
}
9595
}
@@ -171,5 +171,4 @@ class Flutter3DDatasource implements IFlutter3DDatasource {
171171
final result = await _webViewController?.evaluateJavascript(source: code);
172172
return result;
173173
}
174-
175174
}

lib/src/utils/extensions.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import 'dart:ui';
33
extension ColorValue on Color {
44
int get colorValue {
55
return _floatToInt8(a) << 24 |
6-
_floatToInt8(r) << 16 |
7-
_floatToInt8(g) << 8 |
8-
_floatToInt8(b) << 0;
6+
_floatToInt8(r) << 16 |
7+
_floatToInt8(g) << 8 |
8+
_floatToInt8(b) << 0;
99
}
10+
1011
static int _floatToInt8(double x) {
1112
return (x * 255.0).round() & 0xff;
1213
}

0 commit comments

Comments
 (0)