-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write gltf changes #95
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,25 @@ function writeBinaryGltf(gltf, outputPath, createDirectory, callback) { | |
// Correct output path extension if necessary | ||
var outputExtension = path.extname(outputPath); | ||
if (outputExtension !== '.glb') { | ||
outputPath = path.basename(outputPath, outputExtension) + '.glb'; | ||
outputPath = path.join(path.dirname(outputPath), path.basename(outputPath) + '.glb'); | ||
} | ||
// Create the output directory if specified | ||
if (createDirectory) { | ||
outputPath = path.join(path.dirname(outputPath), 'output', path.basename(outputPath)); | ||
mkdirp.sync(path.dirname(outputPath)); | ||
} | ||
mkdirp.sync(path.dirname(outputPath)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change includes all the deleted specs. I thought it was weird that the pipeline won't export a gltf file unless |
||
|
||
var glb = getBinaryGltf(gltf, callback); | ||
fs.writeFile(outputPath, glb, function (err) { | ||
if (err) { | ||
callback(err); | ||
} | ||
var glb = getBinaryGltf(gltf, function(header, scene, body) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This callback was throwing off callbacks that expect an error in the first argument, but instead got the header, scene, body instead. |
||
fs.writeFile(outputPath, glb, function (err) { | ||
if (err) { | ||
if (callback) { | ||
callback(err); | ||
} else { | ||
throw err; | ||
} | ||
} else if (callback) { | ||
callback(undefined, header, scene, body); | ||
} | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer.concat
below didn't like concatting a shader string with a buffer, so I just always wrap the source in a Buffer.