From Unity to Three.js

Over the last several years, Unity has been quietly revolutionising the way we create interactive content. Since we started using it in 2009, it has evolved into a powerful solution for 3D and now 2D development, with remarkable smooth workflows.

Although HTML5 isn’t (yet) among the many platforms Unity supports, we can still take advantage of its robust toolset for our WebGL projects.

The Three.js 3D engine is our library of choice for building interactive experiences for the web. It’s fast, powerful and always getting better.

While working on HelloRun and Lights, we found ourselves increasingly using Unity in the asset pipeline. Initially writing custom JSON exporters for proprietary formats, and later on supporting the native Three.js Object spec.

But these are quick and dirty approaches that require a considerable maintenance effort to keep up with the features of each project and the development of the engine. We want our workflow to rely on existing tools and open formats wherever possible.

This post describes the asset pipeline from the Unity Editor to the Three.js WebGL engine, using the Collada format.

But why use Unity in the first place? The most immediate advantage is that of importing 3D assets and arrange them in the scene with little effort.

And that’s just the beginning, the Unity Asset Store is full of useful packages and plugins covering everything from textures, models and animations to whole project examples, tutorials and editor extensions.

Some tools are great for optimising our models and reduce render time, like Mesh Baker for combining multiple meshes and materials together, or Cruncher for reducing polygon count.

We also rely on the Asset Store for purchasing game-ready 3D models or building them from scratch. There’s plenty of modelling extensions for creating all kinds of objects and a huge library of high quality 3D models at very affordable prices.

On top of that, the Pro version of Unity includes an integrated lightmapping tool that perfectly bakes lights into textures for amazing quality and performance. It leverages Autodesk’s Beast, a set of tools for creating realistic lighting in games, to dramatically enhance the quality of our visuals.

Last but not least, we also use Unity to rapidly prototype our ideas. It’s much faster to iterate with and allows us to try out different concepts and designs quickly.

If you haven’t tried it yet, we suggest you download the free version of Unity and take a look at its excellent learning resources.

Unity can import 3D models, bones, and animations from almost any 3D application, just by dragging the file to the project panel or the Assets directory in the project folder.

Select the model file to display the Import Settings inspector and adjust the scale factor and how normals and tangents are imported.

Also make sure you set the Material Naming option to From Model’s Material, so the original material names are maintained.

For more information about getting your assets into Unity, check out the Importing Models page in the manual or The Project Panel and Importingtutorial.

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

To export assets from Unity we use the Collada Exporter from the Asset Store, a very comprehensive extension with support for animation, skinning, terrain, material properties, lightmaps and physics (colliders, rigid bodies).

The exporter generates a DAE file containing object hierarchy and mesh geometry data in Collada format, a XML-based interchange format that allows information to be easily shared between authoring tools.

An additional feature of this extension is that it creates PNG textures for the included materials, which comes in very handy when using textures with alpha channel.

The file format we use for the exported textures generally depends on whether they have an alpha channel. For 24-bit textures (without alpha channel) we export to JPG format using Photoshop’s Save for Web and Devicesto minimise file size.

If the texture includes an alpha channel we use 32-bit PNG format, but not from Photoshop because it saves transparency instead of alpha. There are ways to solve this, but fortunately the Collada Exporter does it for us and correctly converts PSD files with alpha channel to PNG format.

Since Collada is not a delivery format, it’s not well suited for web applications. We can load DAE files directly into Three.js, but in order to save bandwidth and reduce loading times, it’s preferable to convert them to Three.js native JSON format.

The easiest way to do this is using the Three.js Editor. Just drag the DAE file into the editor and export it back as an Object file. You can repeat this step whenever you need to update your model files to the latest revision of the engine.

We also use the editor to check how models look in WebGL and ensure the conversion has worked correctly without any errors.

If you don’t see your model after it’s been imported, select the root DAE object in the Scene panel and make sure that its scale is not set to zero.

To load the exported Object file into Three.js just use the THREE.ObjectLoaderclass. Make sure you are not using the older THREE.JSONLoader class because it supports a different JSON format.

Please note that due to security restrictions, loading from a file system is not allowed by the browser. When loading models or textures from external files, you need to run from a local server.

Another option is to start Chrome with the allow-access-from-files flag: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome –allow-file-access-from-files (Thanks to Andy for the tip)

In our workflow we usually create materials and shaders from scratch in JavaScript, instead of trying to import them from Unity. This way we know we’re looking at the real thing and can assess quality and performance.

We hope you find this asset pipeline helpful. We work constantly on improving our processes, and we know that many other developers do the same. If you have any question or advice, please leave a comment.

 

[출처] http://helloenjoy.com/2013/from-unity-to-three-js/

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
41 Responsive Web ① – 반응형 웹을 위해 개발자가 꼭 알아야 하는 기술들 file 졸리운_곰 2019.02.08 325
40 서버 사이드 렌더링 그리고 클라이언트 사이드 렌더링 file 졸리운_곰 2018.11.02 800
39 무료 디자인소스 홈페이지들을 소개합니다! file 졸리운_곰 2018.02.27 516
38 스토리보드 템플릿 file 졸리운_곰 2017.10.10 625
37 [웹 기획] 화면 설계 용어 - 와이어프레임, 스토리보드, 프로토타입의 차이점 file 졸리운_곰 2017.10.10 1584
36 웹기획 탄탄한 홈페이지 설계방법 (스토리보드 다운로드) file 졸리운_곰 2017.10.10 2062
35 정보설계(IA : Information Architecture) 졸리운_곰 2016.11.20 329
34 정보 설계 — 웹 사이트 기획 file 졸리운_곰 2016.11.20 756
33 웹 서비스 구축 체크리스트 file 졸리운_곰 2016.10.30 608
32 반응형 웹 기획 file 졸리운_곰 2016.10.27 672
31 [UX 컨설팅] 모 전자 서비스 사례 보고서 secret 졸리운_곰 2016.10.09 0
30 [웹 기획] 기획자가 화면설계서(스토리보드)를 만든다구요? 기획자가 무슨 능력을 가지고 있는데요? 졸리운_곰 2016.10.09 484
29 [UX 디자인] UI 설계도에 해당하는 용어들 file 졸리운_곰 2016.10.09 530
28 [UX 디자인 사례] T모 소프트 "BUX컨설팅소개_V.1.0" file 졸리운_곰 2016.10.09 255
27 [UX 디자인] 사용자 경험(UX)과 사용자 경험 디자인(UX Design) - 위키피디아 정의 살펴보기 file 졸리운_곰 2016.10.08 289
26 [UX 디자인] UX 디자인 조직의 구조와 역할 file 졸리운_곰 2016.10.08 481
25 [UX 디자인] UX 디자인이란? - UI, UX, 인터랙션 디자인의 정의 file 졸리운_곰 2016.10.08 487
24 [UX 디자인] UX(User Experience) 란? UX 디자인 관련 다이어그램 Best 14 file 졸리운_곰 2016.10.08 584
23 [UX 디자인] 7단계 인간행위 모형 - 터치 기기 사용의 행위 모형 file 졸리운_곰 2016.10.08 533
22 [UX 디자인] 애플의 디자인 방법 file 졸리운_곰 2016.10.08 631
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED