-
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
updated getBinaryGltf for gltfs with special characters #253
Changes from 2 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 |
---|---|---|
|
@@ -118,12 +118,15 @@ function getBinaryGltf(gltf, embed, embedImage) { | |
// Remove extras objects before writing | ||
removePipelineExtras(gltf); | ||
|
||
// Create padded binary scene string and calculate total length | ||
// Create padded binary scene buffer and calculate total length | ||
var sceneString = JSON.stringify(gltf); | ||
var sceneLength = Buffer.byteLength(sceneString); | ||
sceneLength += 4 - (sceneLength % 4); | ||
var padding = new Array(sceneLength + 1).join(' '); | ||
sceneString = (sceneString + padding).substring(0, sceneLength); | ||
var sceneBuffer = new Buffer(sceneString); | ||
var sceneLength = sceneBuffer.length; | ||
var paddingLength = 4 - (sceneLength % 4); // pad out to 4 bytes as per glb specification | ||
sceneLength += paddingLength; | ||
var paddingBuffer = new Buffer(paddingLength).fill(' '); | ||
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. Use |
||
var scene = (Buffer.concat([sceneBuffer, paddingBuffer])); | ||
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. No need for the outer parentheses. |
||
|
||
var bodyOffset = 20 + sceneLength; | ||
var glbLength = bodyOffset + body.length; | ||
|
||
|
@@ -135,8 +138,7 @@ function getBinaryGltf(gltf, embed, embedImage) { | |
header.writeUInt32LE(sceneLength, 12); | ||
header.writeUInt32LE(0, 16); | ||
|
||
// Create scene buffer and overall buffer | ||
var scene = new Buffer(sceneString); | ||
// Create overall buffer | ||
var glb = Buffer.concat([header, scene, body], glbLength); | ||
|
||
return { | ||
|
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.
I'm not 100% sure if there was a reason for the padding to be so big before, and then get sliced down to size. Any insights?
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.
I'm not sure either...