Last active
August 29, 2015 14:10
-
-
Save lnznt/89ff6addc4519b143a37 to your computer and use it in GitHub Desktop.
Three.js の JSONLoader のメモ ref: http://qiita.com/lnznt/items/62c2f88f3cc093e83abf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mrdoob-three.js-ca14c79/ | |
├── : | |
└── utils/ | |
├── exporters/ | |
│ ├── blender/ | |
│ │ └── README.md # 説明が書かれている | |
│ │ └── 2.65/ | |
│ │ └── scripts/ | |
│ │ └── addons/ | |
│ │ └── io_mesh_threejs/ # <-- ディレクトリごとコピー |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd mrdoob-three.js-ca14c79/utils/exporters/ | |
$ cd blender/2.65/scripts/addons/ | |
$ sudo cp -r io_mesh_threejs /usr/share/blender/scripts/addons/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loader = new THREE.JSONLoader(); | |
loader.load(uri, function(geometry, materials) { | |
var geo = geometry; | |
var mat = new THREE.MeshFaceMaterial(materials); | |
var mesh = new THREE.Mesh(geo, mat); | |
: | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /usr/share/blender/scripts/addons/ | |
$ sudo find io_mesh_threejs -exec chmod a+r {} \; # ファイル(ディレクトリ含む)に読み取り権を付与 | |
$ sudo find io_mesh_threejs -type d -exec chmod a+x {} \; # ディレクトリに実行権を付与 | |
$ cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loader = new THREE.JSONLoader(); | |
loader.load(uri, function(geometry, materials) { | |
var geo = geometry; | |
var mat = new THREE.MeshFaceMaterial(materials); | |
var mesh = new THREE.Mesh(geo, mat); | |
: | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loader = new THREE.JSONLoader(); | |
loader.load(uri, function(geometry, materials) { | |
var geo = geometry; | |
var mat = new THREE.MeshFaceMaterial(materials); | |
var mesh = new THREE.Mesh(geo, mat); | |
: | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ haml -q sample.haml sample.html | |
$ coffee -c myscript.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ haml -q sample.haml sample.html | |
$ coffee -c myscript.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ haml -q sample.haml sample.html | |
$ coffee -c myscript.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install blender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ markdown README.md | w3m -T text/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install markdown | |
$ sudo apt-get install w3m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
radians = (degree) -> degree * Math.PI / 180 | |
width = 500 | |
height = 300 | |
# scene | |
scene = new THREE.Scene() | |
# mesh | |
new THREE.JSONLoader() | |
.load 'cube.json', (geometry, materials) -> | |
geo = geometry | |
mat = new THREE.MeshFaceMaterial materials | |
mesh = new THREE.Mesh geo, mat | |
mesh.castShadow = true # shadow | |
mesh.scale.set 100, 100, 100 | |
scene.add mesh | |
# mesh (plane) | |
geo = new THREE.PlaneGeometry 500, 500 | |
mat = new THREE.MeshLambertMaterial | |
color : 0x0096d6 | |
side : THREE.DoubleSide | |
plane = new THREE.Mesh geo, mat | |
plane.receiveShadow = true # shadow | |
plane.position.set 0, -150, 0 | |
plane.rotation.x = radians 90 | |
scene.add plane | |
# axis helper | |
scene.add new THREE.AxisHelper 1000 | |
# light | |
light = new THREE.DirectionalLight 0xffffff, 1 | |
light.castShadow = true # shadow | |
light.position.set 0,100,30 | |
scene.add light | |
# ambient light | |
scene.add new THREE.AmbientLight 0x550000 | |
# camera | |
camera = new THREE.PerspectiveCamera 45, width / height, 1, 1000 | |
camera.position.set 200,300,500 | |
# controls (trackball control) | |
controls = new THREE.TrackballControls camera | |
# renderer | |
renderer = new THREE.WebGLRenderer() | |
renderer.shadowMapEnabled = true # shadow | |
renderer.setSize width, height | |
renderer.setClearColor 0xeeeeee, 1 | |
$('#stage').append renderer.domElement | |
# rendering | |
animate = () -> | |
requestAnimationFrame animate | |
renderer.render scene, camera | |
controls.update() | |
animate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! | |
%meta(charset="UTF-8") | |
%title JSONLoader (Three.js) | |
%h1 JSONLoader (Three.js) | |
#stage | |
%script(src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js") | |
%script(src="build/three.min.js") | |
%script(src="js/controls/TrackballControls.js") | |
%script(src="myscript.js") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment