How to load obj model via three.dart?

风格不统一 提交于 2019-12-13 00:23:11

问题


I need to load .obj file exported from blender on my Web app. But I'm not able to find a clear howto example. Example code is very much appreciated.


回答1:


Three.dart does not have OBJLoader yet. But, it has an STLLoader which one can use to load STL models. The loader is not available in the pub.dartlang.org package as of today. You can get the latest vesions of the package on its github page. You can see an example here.




回答2:


You won't get a simple access to your filesystem while using dart on the client side. One option is to access the full blown html5 api's. That includes the FileAPI. The dart team realizes that this is a quite common request (load data into your application) so there is a pretty easy access to data you select via the browser (drag and drop of files is supported as well).

1) FileAPI

A pretty good example is hosted on the dart page itself: https://www.dartlang.org/samples/dndfiles/

The source is available on github and shows you how to get a clear File handle after your data has been uploaded: https://github.com/dart-lang/dart-samples/tree/master/web/html5/file/dndfiles

FYI: This all relies on the Window API (https://api.dartlang.org/docs/channels/stable/latest/dart_html/Window.html)

2) Chrome filesystem

When it comes to local storage you can also (try) to use the chrome api. This however, again, does not give you access to the full file system but only a sandboxed local fs: http://dart-gde.github.io/chrome_gen.dart/app/chrome.fileSystem.html

But before the question "can I access the data from my hard-drive with dart" comes up: Not easily. You can't do that while using your dart application inside the browser. This is forbidden by the browser itself. The only way around it is a native client extension (https://developers.google.com/native-client/pnacl-preview/nacl-and-pnacl). This is probably not what you want to do, though it is definitely possible.



来源:https://stackoverflow.com/questions/20578357/how-to-load-obj-model-via-three-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!