Last active
March 21, 2017 08:16
-
-
Save comoc/9416da98bb1669d9c4bfb7b6d9f11e22 to your computer and use it in GitHub Desktop.
AutodeskのForge Viewerを利用してFBXファイルを表示する ref: http://qiita.com/comocc/items/04e6a06e87d06dac20da
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
curl -v 'https://developer.api.autodesk.com/authentication/v1/authenticate' \ | |
-X 'POST' \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
-d 'client_id=[CLIENT_ID]&client_secret=[CLIENT_SECRET]&grant_type=client_credentials&scope=bucket:create%20bucket:read%20data:write%20data:read' |
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
{"access_token":"[ACCESS_TOKEN]","token_type":"Bearer","expires_in":86399} |
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
curl -X 'POST' \ | |
-H 'Authorization: Bearer '${ACCESS_TOKEN} \ | |
-H 'Content-Type: application/json' \ | |
-v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' \ | |
-d '{"input":{"urn":"'${URN}'"},"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}}' |
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
{"result":"created","urn":"[URN]","acceptedJobs":{"output":{"formats":[{"type":"svf","views":["2d","3d"]}]}},"registerKeys":["[REGISTER_KEYS]"]} |
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
<head> | |
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=no" /> | |
<meta charset="utf-8"> | |
<!-- The Viewer CSS --> | |
<link rel="stylesheet" href="https://developer.api.autodesk.com/viewingservice/v1/viewers/style.min.css" type="text/css"> | |
<!-- Developer CSS --> | |
<style> | |
body { | |
margin: 0; | |
} | |
#MyViewerDiv { | |
width: 100%; | |
height: 100%; | |
margin: 0; | |
background-color: #F0F8FF; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- The Viewer will be instantiated here --> | |
<div id="MyViewerDiv"></div> | |
<!-- The Viewer JS --> | |
<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/three.min.js"></script> | |
<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/viewer3D.min.js"></script> | |
<!-- Developer JS --> | |
<script> | |
var viewer; | |
var options = { | |
env: 'AutodeskProduction', | |
accessToken: '<YOUR_APPLICATION_TOKEN>' | |
}; | |
var documentId = 'urn:<YOUR_URN_ID>'; | |
Autodesk.Viewing.Initializer(options, function onInitialized(){ | |
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure); | |
}); | |
/** | |
* Autodesk.Viewing.Document.load() success callback. | |
* Proceeds with model initialization. | |
*/ | |
function onDocumentLoadSuccess(doc) { | |
// A document contains references to 3D and 2D viewables. | |
var viewables = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {'type':'geometry'}, true); | |
if (viewables.length === 0) { | |
console.error('Document contains no viewables.'); | |
return; | |
} | |
// Choose any of the avialble viewables | |
var initialViewable = viewables[0]; | |
var svfUrl = doc.getViewablePath(initialViewable); | |
var modelOptions = { | |
sharedPropertyDbPath: doc.getPropertyDbPath() | |
}; | |
var viewerDiv = document.getElementById('MyViewerDiv'); | |
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv); | |
viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError); | |
} | |
/** | |
* Autodesk.Viewing.Document.load() failuire callback. | |
*/ | |
function onDocumentLoadFailure(viewerErrorCode) { | |
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode); | |
} | |
/** | |
* viewer.loadModel() success callback. | |
* Invoked after the model's SVF has been initially loaded. | |
* It may trigger before any geometry has been downloaded and displayed on-screen. | |
*/ | |
function onLoadModelSuccess(model) { | |
console.log('onLoadModelSuccess()!'); | |
console.log('Validate model loaded: ' + (viewer.model === model)); | |
console.log(model); | |
} | |
/** | |
* viewer.loadModel() failure callback. | |
* Invoked when there's an error fetching the SVF file. | |
*/ | |
function onLoadModelError(viewerErrorCode) { | |
console.error('onLoadModelError() - errorCode:' + viewerErrorCode); | |
} | |
</script> | |
</body> | |
</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
export ACCESS_TOKEN="[ACCESS_TOKEN]" |
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
export BUCKET_KEY="[BUCKET_KEY]" |
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
curl -v 'https://developer.api.autodesk.com/oss/v2/buckets' \ | |
-X 'POST' \ | |
-H 'Content-Type: application/json' \ | |
-H 'Authorization: Bearer '${ACCESS_TOKEN} \ | |
-d '{"bucketKey":"'${BUCKET_KEY}'","policyKey":"persistent"}' |
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
{"bucketKey":"[BUCKET_KEY]","bucketOwner":"[BUCKET_OWNER]","createdDate":1489572965267,"permissions":[{"authId":"[AUTH_ID]","access":"full"}],"policyKey":"persistent"}% |
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
export FILE_NAME="[FILE_NAME]" |
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
curl -v 'https://developer.api.autodesk.com/oss/v2/buckets/'${BUCKET_KEY}'/objects/'${FILE_NAME} \ | |
-X 'PUT' \ | |
-H 'Authorization: Bearer '${ACCESS_TOKEN} \ | |
-H 'Content-Type: application/octet-stream'\ | |
-H 'Content-Length: '`ls -l ${FILE_NAME} | awk '{print $5}'` \ | |
-T ${FILE_NAME} |
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
{ | |
"bucketKey" : "[BUCKET_KEY]", | |
"objectId" : "urn:adsk.objects:os.object:[BUCKET_KEY]/[FILE_NAME]", | |
"objectKey" : "[FILE_NAME]", | |
"sha1" : "[SHA1]", | |
"size" : [FILE_SIZE], | |
"contentType" : "application/octet-stream-H", | |
"location" : "https://developer.api.autodesk.com/oss/v2/buckets/[BUCKET_KEY]/objects/[FILE_NAME]" | |
* Connection #0 to host developer.api.autodesk.com left intact | |
}* Rebuilt URL to: Content-Length: [FILE_SIZE]/ |
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
export URN="[URN]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment