基于osg-serializier-js
改造,前后端通用的osgb
、osgt
文件解析模块,内置es6版本。
osg-serializier-js is PureJS module for serializing .osgt
and .osgb
files.
The tool is still in development but I will be happy to your issues and contributions
UPDATE: Consider using wasm
using OpenSceneGraph's most updated code (osg-wasm, openscenegraph-cross-platform-guide).
In terminal: npm install --save osg-serializer-browser
In code(node.js):
var filePath = './Samples/cessna.osgb'
osg.readFile(filePath, (err, osgObj) => {
if (err) console.error(err);
else console.log(osgObj);
// start workin with 3d data
})
In code(browser):
<script src='./dist/osg.js'></script>
var buffer = require('buffer')
var filePath = './Samples/cessna.osgb'
fetch(filePath).then(res => { return res.arrayBuffer() }).then(abuf => {
var buf = buffer.Buffer.from(abuf)
var osgObj = osg.readBuffer(buf, filePath)
console.log(osgObj);
})
// start workin with 3d data