This repository was archived by the owner on Dec 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change to "convert glb to wdb"
upgrade wonder.js
- Loading branch information
Showing
10 changed files
with
107 additions
and
208 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
open Wonderjs; | ||
|
||
open Node; | ||
|
||
let convertUint8ArrayToBuffer = [%raw | ||
uint8Array => {| | ||
{ | ||
var buf = new Buffer(uint8Array.byteLength); | ||
for (var i = 0; i < buf.length; ++i) { | ||
buf[i] = uint8Array[i]; | ||
} | ||
return buf; | ||
} | ||
|} | ||
]; | ||
|
||
let buildFakeTextDecoder = [%raw | ||
convertUint8ArrayToBufferFunc => {| | ||
var TextDecoder = function(utfLabel){ | ||
}; | ||
TextDecoder.prototype.decode = (uint8Array) => { | ||
var buffer = convertUint8ArrayToBufferFunc(uint8Array); | ||
return buffer.toString("utf8"); | ||
}; | ||
global.TextDecoder = TextDecoder; | ||
|} | ||
]; | ||
|
||
let buildFakeTextEncoder = | ||
[@bs] | ||
[%raw | ||
() => {| | ||
var TextEncoder = function(){ | ||
}; | ||
TextEncoder.prototype.encode = (str) => { | ||
var buffer = Buffer.from(str, "utf8"); | ||
return buffer; | ||
}; | ||
global.TextEncoder = TextEncoder; | ||
|} | ||
]; | ||
|
||
|
||
let _buildWDBFilePath = (sourceGLBFilePath, destDir) => | ||
Path.join([| | ||
destDir, | ||
Path.basename_ext(sourceGLBFilePath, ".glb") ++ ".wdb", | ||
|]); | ||
|
||
let convert = (sourceGLBFilePath, destDir) => { | ||
let buffer = NodeExtend.readFileBufferSync(sourceGLBFilePath); | ||
|
||
buildFakeTextDecoder(convertUint8ArrayToBuffer); | ||
buildFakeTextEncoder(.); | ||
|
||
buffer##buffer | ||
|> ConverterAPI.convertGLBToWDB | ||
|> WriteWDBSystem.write(_buildWDBFilePath(sourceGLBFilePath, destDir)); | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[@bs.module "fs"] | ||
external readFileBufferSync : string => 'buffer = "readFileSync"; | ||
|
||
[@bs.module "fs"] | ||
external writeFileBufferSync : | ||
(string, 'buffer, [@bs.string] [ | `binary]) => unit = | ||
"writeFileSync"; | ||
|
||
[@bs.new] | ||
external newBufferFromArrayBuffer : | ||
Js.Typed_array.ArrayBuffer.t => Node.Buffer.t = | ||
"Buffer"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
let write = (targetFilePath, wdb) => | ||
NodeExtend.writeFileBufferSync( | ||
targetFilePath, | ||
NodeExtend.newBufferFromArrayBuffer(wdb), | ||
`binary, | ||
); |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
open Wonderjs; | ||
|
||
let readWDB = wdbFilePath => { | ||
let buffer = NodeExtend.readFileBufferSync(wdbFilePath); | ||
|
||
buffer##buffer; | ||
}; | ||
|
||
let getWDFileContent = wdb => { | ||
let (wdFileContent, _) = | ||
BinaryUtils.decode(wdb, AssembleWDBSystem._checkWDB); | ||
|
||
wdFileContent; | ||
}; |
Binary file not shown.
This file was deleted.
Oops, something went wrong.