Last active
March 29, 2018 15:28
-
-
Save bnjm/5684b37f9b906d112afda4ebdcecc88b to your computer and use it in GitHub Desktop.
Example of how to convert 3d.io buffer files for SceneKit
This file contains hidden or 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
const { exec } = require('child_process') | |
const { promisify } = require('util') | |
const { furniture, storage, utils } = require('3dio') | |
const { save, forEachFileInDirectory } from './file' | |
const run = promisify(exec) | |
async function getColladaFiles({ query, directory }) { | |
const redChairs = await furniture.search(query) | |
for (let { fileKey, productResourceId } of redChairs) { | |
await storage.exportDae(fileKey) | |
.then(utils.processing.whenDone) | |
.then(save(directory)) | |
} | |
} | |
async function optimize(inputDir, outputDir) { | |
await forEachFileInDirectory({ directory: inputDir }, file => | |
run( | |
`/Applications/Xcode.app/Contents/Developer/usr/bin/copySceneKitAssets' ${inputDir}/${file} -o ${outputDir}/${file}`, | |
), | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment