Fix buffer init for embedded plugins
This commit is contained in:
@@ -5,10 +5,11 @@ class R {
|
||||
}
|
||||
let r = new R();
|
||||
|
||||
// uv_unwrap.js
|
||||
// import_gltf_glb.js
|
||||
let import_gltf_glb = function(path, done) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let buf = new Uint8Array(r.buffer, a._init(b.bytes.length), b.bytes.length);
|
||||
let buf_off = a._init(b.bytes.length); //// Allocate r.buffer
|
||||
let buf = new Uint8Array(r.buffer, buf_off, b.bytes.length);
|
||||
for (let i = 0; i < b.bytes.length; ++i) buf[i] = b.readU8(i);
|
||||
a._parse();
|
||||
let vertex_count = a._get_vertex_count();
|
||||
@@ -27,7 +28,7 @@ let import_gltf_glb = function(path, done) {
|
||||
scale_pos: a._get_scale_pos(),
|
||||
scale_tex: 1.0
|
||||
});
|
||||
a._destroy();
|
||||
// a._destroy(); //// Destroys r.buffer
|
||||
iron.Data.deleteBlob(path);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ let r = new R();
|
||||
// import_svg.js
|
||||
let import_svg = function(path, done) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let buf = new Uint8Array(r.buffer, a._init(b.bytes.length + 1), b.bytes.length + 1);
|
||||
let buf_off = a._init(b.bytes.length + 1); //// Allocate r.buffer
|
||||
let buf = new Uint8Array(r.buffer, buf_off, b.bytes.length + 1);
|
||||
for (let i = 0; i < b.bytes.length; ++i) buf[i] = b.readU8(i);
|
||||
buf[b.bytes.length] = 0;
|
||||
|
||||
@@ -19,7 +20,7 @@ let import_svg = function(path, done) {
|
||||
let image = core.Image.fromBytes(core.Bytes.ofData(pixels), w, h);
|
||||
done(image);
|
||||
|
||||
a._destroy();
|
||||
// a._destroy(); //// Destroys r.buffer
|
||||
iron.Data.deleteBlob(path);
|
||||
});
|
||||
}
|
||||
@@ -34,4 +35,3 @@ plugin.delete = function() {
|
||||
formats.splice(formats.indexOf("svg"), 1);
|
||||
importers.h["svg"] = null;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ let r = new R();
|
||||
// import_usdc.js
|
||||
let import_usdc = function(path, done) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let buf = new Uint8Array(r.buffer, a._init(b.bytes.length), b.bytes.length);
|
||||
let buf_off = a._init(b.bytes.length); //// Allocate r.buffer
|
||||
let buf = new Uint8Array(r.buffer, buf_off, b.bytes.length);
|
||||
for (let i = 0; i < b.bytes.length; ++i) buf[i] = b.readU8(i);
|
||||
a._parse();
|
||||
let vertex_count = a._get_vertex_count();
|
||||
@@ -27,7 +28,7 @@ let import_usdc = function(path, done) {
|
||||
scale_pos: a._get_scale_pos(),
|
||||
scale_tex: 1.0
|
||||
});
|
||||
a._destroy();
|
||||
// a._destroy(); //// Destroys r.buffer
|
||||
iron.Data.deleteBlob(path);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ function unwrap_mesh(mesh) {
|
||||
mesh.texa = ua16;
|
||||
mesh.inda = ia32;
|
||||
|
||||
a._destroy();
|
||||
// a._destroy(); //// Destroys r.buffer
|
||||
}
|
||||
|
||||
let plugin = new arm.Plugin();
|
||||
|
||||
Reference in New Issue
Block a user