Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WebGL + 3D models by using Three.js Blender Exp...
Search
yomotsu
January 25, 2015
Programming
17k
18
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
WebGL + 3D models by using Three.js Blender Exporter
yomotsu
January 25, 2015
More Decks by yomotsu
See All by yomotsu
three.jsとRapierでレースゲームが3日でできた話
yomotsu
0
880
PBR in three.js
yomotsu
1
1.3k
dialog要素でつくるモーダルダイアログ
yomotsu
0
1.1k
IE to Edge
yomotsu
1
410
A Camera Control Library for three.js
yomotsu
1
1.5k
Let’s try AR on mobile Web with <model-viewer>
yomotsu
0
600
WebXR: Beyond WebGL
yomotsu
2
1.9k
Non-DOM components with WebGL in Vue.js
yomotsu
5
13k
WebGL Libs for WebApp Frameworks
yomotsu
4
7.9k
Other Decks in Programming
See All in Programming
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
140
どこまでゆるくて許されるのか
tk3fftk
0
500
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
240
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
100
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.7k
初めてのKubernetes 本番運用でハマった話
oku053
0
130
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
210
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
110
1B+ /day規模のログを管理する技術
broadleaf
0
140
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.7k
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
350
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
170
Featured
See All Featured
Abbi's Birthday
coloredviolet
3
8.7k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
450
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Typedesign – Prime Four
hannesfritz
42
3.1k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Building the Perfect Custom Keyboard
takai
2
810
From π to Pie charts
rasagy
0
240
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Invisible Side of Design
smashingmag
301
52k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
Transcript
WebGL + 3D models by using Three.js Blender Exporter Presented
by Akihiro Oyamada (@yomotsu) Jan 25, 2015
Frontend Engineer at PixelGrid, Inc. @yomotsu recent works • http://yomotsu.github.io/walkthrough/
• http://yomotsu.github.io/xmas2014/ Akihiro Oyamada
Download the hands-on material https://github.com/tokyowebglmeetup/ h5conf2015_session2/
three.js and Blender
5 http://threejs.org/
6 http://www.blender.org/
WebGL + 3D models is much more fun!
You don't make 3D models? There are many 3D models
with open license!
9 http://nasa3d.arc.nasa.gov/
10 http://blendswap.com/
11 https://www.yobi3d.com/
Now you can prepare 3D models. How do we convert
3D models to WebGL?
three.js Blender exporter!
FYI We use previous exporter r69 The brand new exporter
(r70) is still limited a bit, as of January 2015
How to install Blender exporter
Download three.js r69 for previous blender exporter 16 https://github.com/mrdoob/three.js/releases/tag/r69
Although, we don't use this time, You can get latest
three.js package for the new Exporter, from GitHub 17 https://github.com/mrdoob/three.js or FYI
Copy io_three folder three.js-r69 ... utils exporters blender 2.65 scripts
addons io_three
Put io_three into following place Windows: C:\Program Files\Blender Foundation\Blender\2.7X\scripts\addons\
Mac OSX: /Applications/blender.app/Contents/Resources/2.7X/scripts/addons/
Can’t Open Blender as a folder in your Mac? Just
right click, then Show Package Contents
Macintosh HD/Applications/blender.app/Contents/Resources/2.7X/scripts/addons/ C:\Program Files\Blender Foundation\Blender\2.7X\scripts\addons\
Launch Blender
File > User Preferences
Type in three in the search box
Mark to activate
Press Save User Setting button
Now three.js Exporter is ready!
1. Download three.js package 2. Copy io_three folder 3. Put
it into scripts/addons folder of Blender 4. Active the addon under User Preferences > Addons SFWJFX
How to publish a 3D model
we are gonna use alfaromeo.blend html5conf/session2 _original 1_object alfaromeo.blend ...
...
None
Mouse TrackPad Rotate Pan Zoom Select CBTJDPQFSBUJPO + shift +
shift
Mouse TrackPad Translate Rotate Scale Delete CBTJDPQFSBUJPO → G →
R → S → G → R → S Z Z
None
Mark following options, then save it.
You will have a JSON file and texture images model
data texture textu
How to append the 3D model into a Web page
var width = window.innerWidth, height = window.innerHeight, clock = new
THREE.Clock(), scene, camera, renderer, ambientLight, directionalLight, loader, alfaromeo = new THREE.Object3D(); ! scene = new THREE.Scene(); ! camera = new THREE.PerspectiveCamera( 40, width / height, 1, 1000 ); camera.position.set( 0, 1, 5 ); ! renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setSize( width, height ); document.body.appendChild( renderer.domElement ); write code as usual
directionalLight, loader, alfaromeo = new THREE.Object3D(); ! scene = new
THREE.Scene(); ! camera = new THREE.PerspectiveCamera( 40, width / height, 1, 1000 ); camera.position.set( 0, 1, 5 ); ! renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setSize( width, height ); document.body.appendChild( renderer.domElement ); ! ambientLight = new THREE.AmbientLight( 0xffffff ) scene.add( ambientLight ); ! directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add( new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); write code as usual
camera.position.set( 0, 1, 5 ); ! renderer = new THREE.WebGLRenderer(
{ antialias: true } ); renderer.setSize( width, height ); document.body.appendChild( renderer.domElement ); ! ambientLight = new THREE.AmbientLight( 0xffffff ) scene.add( ambientLight ); ! directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add( new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); loader.load( 'alfaromeo.json', function( geometry, materials ) { ! alfaromeo = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) ); ! write code as usual
! ambientLight = new THREE.AmbientLight( 0xffffff ) scene.add( ambientLight );
! directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add( new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); loader.load( 'alfaromeo.json', function( geometry, materials ) { ! alfaromeo = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) ); ! scene.add( alfaromeo ); ! } ); ! ( function renderLoop () { write code as usual
! ambientLight = new THREE.AmbientLight( 0xffffff ) scene.add( ambientLight );
! directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add( new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); loader.load( 'alfaromeo.json', function( geometry, materials ) { ! alfaromeo = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) ); ! scene.add( alfaromeo ); ! } ); ! ( function renderLoop () { make a loader
directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add(
new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); loader.load( 'alfaromeo.json', function( geometry, materials ) { ! alfaromeo = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) ); ! scene.add( alfaromeo ); ! } ); ! ( function renderLoop () { ! requestAnimationFrame( renderLoop ); var elapsed = clock.getElapsedTime(); alfaromeo.rotation.y = elapsed / 2; renderer.render( scene, camera ); use load method
directionalLight.position.set( 0, 1, 0 ); scene.add( directionalLight ); ! scene.add(
new THREE.GridHelper( 10, 1 ) ); ! loader = new THREE.JSONLoader(); loader.load( 'alfaromeo.json', function( geometry, materials ) { ! alfaromeo = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) ); ! scene.add( alfaromeo ); ! } ); ! ( function renderLoop () { ! requestAnimationFrame( renderLoop ); var elapsed = clock.getElapsedTime(); alfaromeo.rotation.y = elapsed / 2; renderer.render( scene, camera ); make call back
new THREE.MeshFaceMaterial( materials ) ); ! scene.add( alfaromeo ); !
} ); ! ( function renderLoop () { ! requestAnimationFrame( renderLoop ); var elapsed = clock.getElapsedTime(); alfaromeo.rotation.y = elapsed / 2; renderer.render( scene, camera ); ! } )(); render it!
None
How to publish a 3D model with animations
None
Apply rest pose 1. go to Pose Mode 2. select
all bones 3. Pose > Clear Transform > All 4. ctrl + A 5. Apply Location 6. ctrl + A 7. Apply Rotation 8. ctrl + A 9. Apply Scale
Mark following options, and set Frame step. then save it.
load JSON
active skinning
make a SkinnedMesh
make animations
add it
start an animation
update animations
None
TIPS
Blender exporter does not support CJK letters for names of
geometries, materials, bones and others. Replace them to ascii
Since WebGL work on web browsers, .tga image format is
not supported. use PNG images instead.
three.js does not support IK, Bake as FK in Blender
see http://yomotsu.net/blog/2014/02/19/convert-mmd-for- threejs.html
If you publish a model with animations, set rest pose
in Blender see http://stackoverflow.com/questions/18752146/blender- exports-a-three-js-animation-bones-rotate-strangely/ 18770716#18770716
The New Blender Exporter Features
• BufferGeometry • Precision for float numbers • Debug logging
gl.finish(); @yomotsu