wasabia / three_dart

three.js rewrite by Dart, Dart 3D library. an easy to use, lightweight, cross-platform, general purpose 3D library.
MIT License
450 stars 80 forks source link

All glb or glft files cannot be opened #133

Open zhazhazsy opened 1 year ago

zhazhazsy commented 1 year ago

E/flutter (19589): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: NoSuchMethodError: Class 'GLTFParser' has no instance getter '_markDefs'. E/flutter (19589): Receiver: Instance of 'GLTFParser' E/flutter (19589): Tried calling: _markDefs E/flutter (19589): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) E/flutter (19589): #1 GLTFParser.parse. (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:96:18) E/flutter (19589): #2 GLTFParser._invokeAll (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:203:30) E/flutter (19589): #3 GLTFParser.parse (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:95:5) E/flutter (19589): #4 GLTFLoader.parse (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart:276:12) E/flutter (19589): #5 GLTFLoader.load. (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart:115:13) E/flutter (19589): #6 FileLoader.load (package:three_dart/three3d/loaders/file_loader.dart:200:57) E/flutter (19589): E/flutter (19589): I/flutter (19589): set values roughness: 1.0 E/flutter (19589): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: NoSuchMethodError: The method '<=' was called on null. E/flutter (19589): Receiver: null E/flutter (19589): Tried calling: <=(1) E/flutter (19589): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) E/flutter (19589): #1 GLTFParser._getNodeRef (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:177:30) E/flutter (19589): #2 GLTFParser.createNodeMesh (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:1275:23) E/flutter (19589): E/flutter (19589): #3 GLTFParser._invokeOne (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:191:20) E/flutter (19589): E/flutter (19589): #4 GLTFParser.loadNode (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:1306:23) E/flutter (19589): E/flutter (19589): #5 GLTFParser.getDependency (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:228:24) E/flutter (19589): E/flutter (19589): #6 GLTFParser.buildNodeHierarchy (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:1412:16) E/flutter (19589): E/flutter (19589): #7 GLTFParser.loadScene (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:1490:7) E/flutter (19589): E/flutter (19589): #8 GLTFParser.getDependency (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:224:24) E/flutter (19589): E/flutter (19589): #9 GLTFParser.getDependencies (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:304:17) E/flutter (19589): E/flutter (19589): #10 GLTFParser.parse (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:99:20) E/flutter (19589): E/flutter (19589):

Knightro63 commented 1 year ago

Hi @zhazhazsy,

I have noticed that error as well. Have you tried an older version of this repo e.g.(three_dart: 0.0.14 and three_dart_jsm:0.0.9)? If those don't work please try : three_dart: git: url: https://github.com/Knightro63/three_dart.git three_dart_jsm: git: url: https://github.com/Knightro63/three_dart_jsm.git

BobaTrek commented 1 year ago

I am having similar problems.

FYI: Even the online version is failing to load glft files: Go to https://wasabia.github.io/three_dart_example/ and click on the loader / glft example and you just get a black screen.

Edit: I tried downloading the Examples from the repository so I could run them on my local machine's android emulator. When I did, the program threw an exception with the following message: NoSuchMethodError: Class 'GLTFParser' has no instance getter '_markDefs'. Receiver: Instance of 'GLTFParser' Tried calling: _markDefs

Here is the section of code that threw from object_patch.dart:

@patch @pragma("vm:entry-point", "call") dynamic noSuchMethod(Invocation invocation) { // TODO(regis): Remove temp constructor identifier 'withInvocation'. throw new NoSuchMethodError.withInvocation(this, invocation); }

which was called from this section in gltf_parser.dart: // Mark the special nodes/meshes in json for efficient parse _invokeAll((ext) { return ext._markDefs != null && ext._markDefs() != null; });

which was called from this section also in gltf_parser.dart: for (var i = 0; i < extensions.length; i++) { var result = await func(extensions[i]);

Unsure if it is the same problem, but I hope this info helps.

Here is the Debug terminal output: E/flutter (26816): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NoSuchMethodError: Class 'GLTFParser' has no instance getter '_markDefs'. E/flutter (26816): Receiver: Instance of 'GLTFParser' E/flutter (26816): Tried calling: _markDefs E/flutter (26816): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) E/flutter (26816): #1 GLTFParser.parse. (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:96:18) E/flutter (26816): #2 GLTFParser._invokeAll (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:203:30) E/flutter (26816): #3 GLTFParser.parse (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart:95:5) E/flutter (26816): #4 GLTFLoader.parse (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart:276:12) E/flutter (26816): #5 GLTFLoader.load. (package:three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart:115:13) E/flutter (26816): #6 FileLoader.load (package:three_dart/three3d/loaders/file_loader.dart:199:57) E/flutter (26816): E/flutter (26816): I/flutter (26816): loader: Instance of 'TextureLoader' I/flutter (26816): loader: Instance of 'TextureLoader' I/flutter (26816): loader: Instance of 'TextureLoader' I/flutter (26816): loader: Instance of 'TextureLoader' I/flutter (26816): set values roughness: 1.0

BobaTrek commented 1 year ago

I just tried running on my local PC as a web app and basically saw the same thing. Here is the Debug output:

OpenGLContextWeb {gl: [object WebGL2RenderingContext]} loader: Instance of 'TextureLoader' Error: NoSuchMethodError: '_markDefs' method not found Receiver: Instance of 'GLTFParser' Arguments: [] dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 288:49 throw dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 813:3 defaultNoSuchMethod dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 64:17 noSuchMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 808:31 noSuchMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 135:10 dload packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 96:36 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39 dcall packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 203:30 _invokeAll dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 196:13 [_invokeAll] packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 95:5 parse dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 86:8 parse packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart 276:11 parse packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_loader.dart 115:12 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39 dcall packages/three_dart/three3d/loaders/file_loader.dart 199:67 load dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 147:18 handleValue dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 657:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15 loader: Instance of 'TextureLoader' loader: Instance of 'TextureLoader' loader: Instance of 'TextureLoader' loader: Instance of 'TextureLoader' set values roughness: 1 Error: NoSuchMethodError: '<=' Dynamic call of null. Receiver: null Arguments: [1] dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 288:49 throw dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 813:3 defaultNoSuchMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 807:56 noSuchMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 283:12 callNSM dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 294:25 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:10 callMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 435:5 dsend packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 177:30 [_getNodeRef] packages/three_dart_jsm/three_dart_jsm/loaders/gltf/gltf_parser.dart 1275:22 createNodeMesh dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 147:18 handleValue dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue] dart-sdk/lib/async/future.dart 531:22 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 147:18 handleValue dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 657:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15

BobaTrek commented 1 year ago

Hi @zhazhazsy,

I have noticed that error as well. Have you tried an older version of this repo e.g.(three_dart: 0.0.14 and three_dart_jsm:0.0.9)? If those don't work please try : three_dart: git: url: https://github.com/Knightro63/three_dart.git three_dart_jsm: git: url: https://github.com/Knightro63/three_dart_jsm.git

I tried this:

dependency_overrides: three_dart: git: https://github.com/Knightro63/three_dart.git three_dart_jsm: git: https://github.com/Knightro63/three_dart_jsm.git

but I get a bunch of compilation errors regarding 'pi' not being found:

lib/misc_animation_keys.dart:233:72: Error: Member not found: 'pi'. var qFinal = three.Quaternion().setFromAxisAngle(xAxis, three.Math.pi); ^^ lib/webgl_animation_cloth.dart:447:35: Error: Member not found: 'pi'. mesh.rotation.x = -three.Math.pi / 2; ^^ lib/webgl_animation_multiple.dart:253:46: Error: Member not found: 'pi'. "rotation": {"x": 0, "y": three.Math.pi, "z": 0}, ^^ lib/webgl_animation_multiple.dart:261:46: Error: Member not found: 'pi'. "rotation": {"x": 0, "y": three.Math.pi / 2, "z": 0}, ^^

Knightro63 commented 1 year ago

Hi @BobaTrek

I just tried it with the examples and had no issue.

Move them from dependency_overrides: to dependencies:

don't have anything in the dependency_overrides section.

run flutter clean, flutter pub upgrade.

It looks like it is trying to use the newer versions of three_dart, because Math.pi is in 0.0.16 not 0.0.14

BobaTrek commented 1 year ago

I appear to be chasing my tail. I have tried all sorts of combinations but I either get dependency cannot be resolved due to various version requirements, or I get the 'pi' member missing issue.

What exact repos (wasabia or Knightro63) and versions should I be using? three_dart: three_dart_jsm: flutter_gl: universal_ui: (if needed)

Also, what repo of the example code should I be using?

I have tried the example code in the wasabia repo version 0.0.16 and the main surface. When I tried 0.0.14, I get the following: Resolving dependencies... The current Dart SDK version is 3.0.0. Because example depends on universal_ui >=0.0.6 which doesn't support null safety, version solving failed. The lower bound of "sdk: '>=2.7.0 <3.0.0'" must be 2.12.0 or higher to enable null safety. For details, see https://dart.dev/null-safety

Thanks!

BobaTrek commented 1 year ago

I downloaded the latest code and example from Knightro63. Compiling, here are the dependencies it is showing that I am using: ! three_dart 0.0.14 from path ..\three_dart-Knightro63 (overridden) ! three_dart_jsm 0.0.9 from git https://github.com/Knightro63/three_dart_jsm.git at 3f6583 (overridden) flutter_gl 0.0.21

Here is the output when I try to load the DamagedHelmet example: OpenGLContextWeb {gl: [object WebGL2RenderingContext]} Error: RangeError (end): Invalid value: Only valid value is 0: 128 dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 288:49 throw dart-sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart 1818:5 _checkValidRange dart-sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart 1064:16 sublist] packages/three_dart_jsm/three_dart_jsm/loaders/RGBELoader.dart 70:46 packages/three_dart_jsm/three_dart_jsm/loaders/RGBELoader.dart 133:23 packages/three_dart_jsm/three_dart_jsm/loaders/RGBELoader.dart 336:43 parse packages/three_dart/three3d/loaders/DataTextureLoader.dart 22:26 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39 dcall packages/three_dart/three3d/loaders/FileLoader.dart 199:67 load dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 147:18 handleValue dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 657:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15

Is that info helpful at all?

Here is what I get if II try to load coffeemat.glb: (I highlighted in bold an interesting complaint about setKTX2Loader) OpenGLContextWeb {gl: [object WebGL2RenderingContext]} Error: THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 288:49 throw packages/three_dart_jsm/three_dart_jsm/loaders/gltf/GLTFExtensions.dart 619:9 loadTexture2 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:10 callMethod dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 435:5 dsend packages/three_dart_jsm/three_dart_jsm/loaders/gltf/GLTFParser.dart 271:29 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async packages/three_dart_jsm/three_dart_jsm/loaders/gltf/GLTFParser.dart 269:47 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37 _checkAndCall dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39 dcall packages/three_dart_jsm/three_dart_jsm/loaders/gltf/GLTFParser.dart 195:30 _invokeOne dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 147:18 handleValue dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 657:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15

BobaTrek commented 1 year ago

I made some progress with the following:

I downloaded the example and three_dart from the Knightro63 repository.

I am using the following dependencies in pubspec.yaml: three_dart: ^0.0.13 three_dart_jsm: git: url: 'https://github.com/Knightro63/three_dart_jsm.git'

universal_ui: ^0.0.8

flutter_gl: ^0.0.20

dependency_overrides: three_dart: path: ../

I had to comment out the universal_ui dependency because it was causing the following error: Because example depends on universal_ui >=0.0.6 which doesn't support null safety, version solving failed.

I then ran under chrome and the DamagedHelmet gltb file loaded fine, but only on the first invocation. Edit: Currently, I can only go from the front page listview to the DamagedHelmet scene once per run. The first time I go to the DamaagedHelmet scene, the helmet appears. Every time after that, I only get the black screen with the filename at the top and the render button at the bottom. Clicking the render button does nothing. The same one-time only behavior is also observed on some of the other example pages like 'loader / obj / mtl' and 'animation / keyframes'.

I then tried to run it under Android and I got some compilation errors that I had to sort through:

1) I got complaints about the Gradle version so I ran the AGP Assistant and upgraded to Gradle version 7.5.0

2) I got the following error:

So I went to the build.gradle file of the android project and changed the line that said: ext.kotlin_version = '1.3.61' to: ext.kotlin_version = '1.5.20'

3) I then got build error saying that as of Android version 13, android:exported must be explicitly declared in main\AndroidManifest.xml so I added it here: <activity android:name=".MainActivity" android:exported="true" I don't know if it should have been true or false

That got rid of all of the compilation errors for Android.

I launched Android, and the main page showing the list of examples and their pictures comes up.

But if I click on any of them (I only tried a few so far), I get the black background for the 3D view, but then the Android emulator shuts down and goes away.

Here is the output of the Debug console when I selected the Geometries / Color example from the list on the front page:

Launching lib\main.dart on AOSP on IA Emulator in debug mode... Running Gradle task 'assembleDebug'... √ Built build\app\outputs\flutter-apk\app-debug.apk. W/FlutterActivityAndFragmentDelegate( 4264): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps. Debug service listening on ws://127.0.0.1:53082/V9I7H4d7Ui8=/ws Syncing files to device AOSP on IA Emulator... D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 0 (0) 1 0 D/HostConnection( 4264): HostConnection::get() New Host Connection established 0xced78f60, tid 4394 D/HostConnection( 4264): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 0 (0) 0 0 D/EGL_emulation( 4264): eglCreateContext: 0xc9951e00: maj 3 min 1 rcv 4 D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 0 (0) 0 0 D/EGL_emulation( 4264): eglCreateContext: 0xc9951e60: maj 3 min 1 rcv 4 D/com.futouapp.flutter_gl.flutter_gl.EglEnv( 4264): egl make current D/EGL_emulation( 4264): eglMakeCurrent: 0xc9951e60: ver 3 1 (tinfo 0xc0d7fdf0) E/eglCodecCommon( 4264): glUtilsParamSize: unknow param 0x000082da E/eglCodecCommon( 4264): glUtilsParamSize: unknow param 0x000082da D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 0 (0) 0 0 D/EGL_emulation( 4264): eglCreateContext: 0xc9951fe0: maj 3 min 1 rcv 4 D/HostConnection( 4264): HostConnection::get() New Host Connection established 0xced75db0, tid 4285 D/HostConnection( 4264): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 D/EGL_emulation( 4264): eglMakeCurrent: 0xc9951fe0: ver 3 1 (tinfo 0xced12720) E/eglCodecCommon( 4264): glUtilsParamSize: unknow param 0x000082da E/eglCodecCommon( 4264): glUtilsParamSize: unknow param 0x000082da I/flutter ( 4264): set vertexColors: true I/flutter ( 4264): before animate render mounted: true loaded: true I/flutter ( 4264): animate render D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 1 (1) 15 0 E/emuglGLESv2_enc( 4264): a vertex attribute index out of boundary is detected. Skipping corresponding vertex attribute. buf=0xcee184e0 E/emuglGLESv2_enc( 4264): Out of bounds vertex attribute info: clientArray? 0 attribute 0 vbo 1 allocedBufferSize 48 bufferDataSpecified? 1 wantedStart 0 wantedEnd 357528 E/emuglGLESv2_enc( 4264): a vertex attribute index out of boundary is detected. Skipping corresponding vertex attribute. buf=0xcee184e0 E/emuglGLESv2_enc( 4264): Out of bounds vertex attribute info: clientArray? 0 attribute 0 vbo 1 allocedBufferSize 48 bufferDataSpecified? 1 wantedStart 0 wantedEnd 357528 E/emuglGLESv2_enc( 4264): a vertex attribute index out of boundary is detected. Skipping corresponding vertex attribute. buf=0xcee184e0 E/emuglGLESv2_enc( 4264): Out of bounds vertex attribute info: clientArray? 0 attribute 0 vbo 1 allocedBufferSize 48 bufferDataSpecified? 1 wantedStart 0 wantedEnd 357528 D/eglCodecCommon( 4264): setVertexArrayObject: set vao to 2 (2) 1 0 Lost connection to device. adb.exe: device offline

Knightro63 commented 1 year ago

Hi @BobaTrek,

I am sorry you having problems with all of the repos. So I restarted everything to see if I could mimic the problems you are experiencing.

I also kept getting a universal_ui error so I commented it out. I then was getting a universal_html: ^2.0.8 null check on text.

I had very similar issues with Android. I also had to change flutter_gl ext.kotlin_version = '1.5.20', but I was getting other errors so I deleted the android folder and ran: flutter create . --platform android I added the libs file under app, changed the AndroidManifest.xml, and modified the app/src/buld.gradle files sdk versions.

I have updated my repo to reflect the changes that were made. I ran it on a a pixel 6 pro emulator, a samsung device, macos, and web and was able to see the helmet on all of them.

Can you try redownloading the github repo and run the example again you might need to run flutter clean and flutter pub upgrade to update the pub-cache with the changes.

BobaTrek commented 1 year ago

Hmm. I repeated your steps and was able to build, but I still run into two problems:

1) Running under Chrome, I can pick the helmet example once, see it render, then go back to the main page, pick the helmet a second time, and it no longer renders.

2) Running under pixel 6 pro emulator, when I pick the helmet, I can see that the file loads fine based on the debug output that says "gtlf load sucess result" (note the misspelled success). I get the following debug output, and the emulator vanishes: D/EGL_emulation( 2861): eglMakeCurrent: 0xf3b5a790: ver 3 0 (tinfo 0xd2de70d0) (first time) I/flutter ( 2861): Important warn: make sure set samples before setRenderTarget
I/flutter ( 2861): loader: Instance of 'TextureLoader' I/flutter ( 2861): loader: Instance of 'TextureLoader' I/flutter ( 2861): loader: Instance of 'TextureLoader' I/flutter ( 2861): loader: Instance of 'TextureLoader' I/flutter ( 2861): loader: Instance of 'TextureLoader' I/flutter ( 2861): set values roughness: 1.0 I/flutter ( 2861): gltf load sucess result: {scene: Instance of 'Group', scenes: [Instance of 'Group'], animations: [], cameras: [], asset: {generator: Khronos Blender glTF 2.0 exporter, version: 2.0}, parser: Instance of 'GLTFParser', userData: {}}
E/emuglGLESv2_enc( 2861): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glPixelStorei:541 GL error 0x500 E/emuglGLESv2_enc( 2861): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glPixelStorei:541 GL error 0x500 I/flutter ( 2861): BufferGeometry dispose ........... I/flutter ( 2861): WebGLBindingStates releaseStatesOfProgram Lost connection to device. adb.exe: device offline

I then downloaded everything from your repository and recompiled. The results were identical.

Could you please check and make sure that you can load the helmet example more than just once per run?

Is there anything special that needs to be done to get the Android emulator to work with three.js? I did go into "Extended Controls" and then "Settings" and changed OpenGL ES level to "Renderer maximum (up to OpenGL ES 3,1)".

BobaTrek commented 1 year ago

When you run successfully, do you also get the GL error 0x500 messages?

It is coming from the following GL code with the GL_INVALID_ENUM error code located here: void GL2Encoder::s_glPixelStorei(void self, GLenum param, GLint value)  {   GL2Encoder ctx = (GL2Encoder *)self;   SET_ERROR_IF(!GLESv2Validation::pixelStoreParam(ctx, param), GL_INVALID_ENUM);   SET_ERROR_IF(!GLESv2Validation::pixelStoreValue(param, value), GL_INVALID_VALUE);   ctx->m_glPixelStorei_enc(ctx, param, value);   assert(ctx->m_state != NULL);   ctx->m_state->setPixelStore(param, value);  }  

The wiki shows this information about the error code 0x500 GL_INVALID_ENUM:

Knightro63 commented 1 year ago

Hi @BobaTrek,

I do not get the error GL error 0x500. I was wondering what type of os you are using?

I have set OpenGL ES level to Renderer maximum (up to OpenGL ES 3,1) and I still was able to run no problem. Can you check your emulator vm heap, ram, and internal storage to make sure they are not set too low. I am also running Android 13 on the emulator with emulated performance set to Automatic, and multi-core CPU.

To fix the problem with the web not loading more than once you might need to add THREE.loading = {}; to the dispose function. This variable is a global variable in FileLoader and because of that Flutter web makes everything into one large js file and all globals stay globals and are not removed when disposing widgets.

lorisgir commented 7 months ago

Hi all, I'm getting 'Error: THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' How can I fix this? I'm already using Knightro63 repos...

Edit: I'm also getting the 0x500 error: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glPixelStorei:644 GL error 0x500 condition [!GLESv2Validation::pixelStoreParam(ctx, param)]