Skip to content

Instantly share code, notes, and snippets.

@sterlingwes
Created May 10, 2017 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sterlingwes/ddca0c2fac82f2041bd8ee73a476c03f to your computer and use it in GitHub Desktop.
Save sterlingwes/ddca0c2fac82f2041bd8ee73a476c03f to your computer and use it in GitHub Desktop.
Three.js OBJ Loader test
<html>
<head>
<script src="node_modules/three/build/three.js"></script>
<script src="node_modules/three/examples/js/loaders/OBJLoader.js"></script>
</head>
<body>
<script>
const model = 'https://s3.amazonaws.com/areo-dev-wjohnson/v1/worlds/a42d78b1-a28a-4d7b-b64e-c1512ea9bac4/models/a4cd6444-fa12-4edf-aba5-8aa72e693bc6-m'
fetch(model)
.then(response => response.blob())
.then(blob => read(blob))
.then(model => load(model))
.then(json => console.log(json))
function read (blob) {
return new Promise(resolve => {
const reader = new FileReader()
reader.addEventListener('load', evt => {
resolve(reader.result)
})
reader.readAsText(blob)
})
}
function load (text) {
const loader = new THREE.OBJLoader()
return loader.parse(text)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment