Hi, when only using the engine the parse(data) and load()only seems to support STL:
parse(data) {
return new Promise((accept, reject) => {
try {
let vertices = new load.STL().parse(data);
this.listener({parsed: data, vertices});
this.widget.loadVertices(vertices).center();
accept(this);
} catch (error) {
reject(error);
}
});
}
Why not also add support for 3mf using the existing functions?
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
'use strict';
// dep: add.three
// dep: ext.jszip
gapp.register('load.3mf', [], (root, exports) => {
let load = self.load = self.load || {};
if (load.TMF) return;
load.TMF = {
parseAsync
};
load.XML = {
query
};
This file has been truncated. show original
Thank you,
Atam Panday
certainly doable. very few people use this code and it’s never been requested. I would welcome a PR to make this change. 3MF was added long after the engine code existed
haha I don’t know npm stuff, like e.g. how to build a new engine.js?
But maybe I can help with this?
replace dep: load.stl with load.file?
load(url) {
return new Promise((accept, reject) => {
try {
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`Failed to fetch URL: ${response.statusText}`);
}
return response.arrayBuffer();
})
.then(buffer => {
const fileName = url.split('/').pop();
load.File.load_data(buffer, fileName)
.then(fileDataArray => {
fileDataArray.forEach(fileData => {
const { mesh } = fileData;
this.listener({ loaded: url, vertices: mesh });
this.widget.loadVertices(mesh).center();
});
accept(this);
})
.catch(reject);
})
.catch(reject);
} catch (error) {
reject(error);
}
});
}
parse(data, file) {
return new Promise((accept, reject) => {
try {
load.File.load_data(data, file)
.then(fileDataArray => {
fileDataArray.forEach(fileData => {
const { mesh } = fileData;
this.listener({ parsed: data, vertices: mesh });
this.widget.loadVertices(mesh).center();
});
accept(this);
})
.catch(reject);
} catch (error) {
reject(error);
}
});
}
I used AI for this, I’m not a front-end developer so probably full of bugs
AI code gen is just going to produce trash. let’s not further pollute the internet archive with bad data for it to feed on.
1 Like
Can you give some tips how i can generate a new code/engine.js to test locally if I change the code?
stewart
January 30, 2025, 11:45pm
6
have you followed the readme to run everything locally? it’s quite simple
Hi Stewart,
I don’t control my backend.
I can only include the code/engine.js in the frontend. This means, I cannot launch the whole framework using npm/nodejs.
I also miss notes in the Readme how to generate/export a new code/engine.js if I change the code and need to test it. Without testing I cannot work on a PR.
With npm build I can create new:
KiriMoto-linux-x64.zip
KiriMoto-linux-x86_64.AppImage
But not a new engine.js like at https://grid.space/code/engine.js
How do I do that?
Thanks, Atam
the code/engine.js
file is not present in the file-system because it is a composite of multiple code fragments in the system. it is generated by the back-end server at startup and served from a memory cache.
haha that explains, I will try it out
Hi Stewart, I need some help here.
The original engine.js (https://grid.space/code/engine.js ) is 942 KiB
When I run locally e.g.
npm i
sudo npm install -g @gridspace/app-server
gs-app-server
or on newest branches:
npm run setup
npm run start
I can download it from either
http://localhost:8080/code/engine.js
or
http://localhost:5309/code/engine.js
I tried master, rel-4.1 and rel-4.0 branches.
All produce a engine.js of 1.4 to 1.5 MiB which is different.
Also, in my test the original engine works:
this.engine = kiri.newEngine();
this.engine.parse(data);
However, all the custom builds, with no code change give some error
parse https://kubify.nl/code/engine.js:600 TypeError: r is undefined
So how can I generate the same engine.js locally as the live one?
Which branch is used live?
Once I can reproduce that, I can try and make the change and test it.
But I need the baseline.