Skip to content

Commit

Permalink
Add node and browser example.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jan 28, 2022
1 parent 123ab27 commit c545dbe
Show file tree
Hide file tree
Showing 8 changed files with 1,042 additions and 7 deletions.
504 changes: 504 additions & 0 deletions dist/license.occt-import-js.txt

Large diffs are not rendered by default.

502 changes: 502 additions & 0 deletions dist/license.occt.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/occt-import-js.js

Large diffs are not rendered by default.

Binary file modified dist/occt-import-js.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
"converter"
],
"devDependencies": {
"http-server": "^0.12.3",
"mocha": "^8.3.2"
},
"scripts": {
"start": "http-server",
"test": "mocha test/test.js"
},
"dependencies": {}
Expand Down
1 change: 1 addition & 0 deletions start_server.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm start
28 changes: 28 additions & 0 deletions test/browser_step.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">

<title>OcctImportJS Demo</title>
<script type="text/javascript" src="../dist/occt-import-js.js"></script>

<script type='text/javascript'>
window.onload = function () {
occtimportjs ().then (async function (occt) {
let fileUrl = 'testfiles/simple-basic-cube/cube.stp';
let response = await fetch (fileUrl);
let buffer = await response.arrayBuffer ();
let fileBuffer = new Uint8Array (buffer);
let result = occt.ReadStepFile (fileBuffer);
console.log (result);
});
};
</script>
</head>

<body>
</body>

</html>
10 changes: 4 additions & 6 deletions test/node_step.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
let fs = require ('fs');
const occtImportJS = require ('../build_wasm/Release/occt-import-js.js')();
const occtimportjs = require ('../dist/occt-import-js.js')();

console.log ('started');
occtImportJS.then ((occt) => {
console.log ('loaded');
let fileContent = fs.readFileSync ('testfiles/simple-basic-cube/cube.stp');
occtimportjs.then ((occt) => {
let fileUrl = 'testfiles/simple-basic-cube/cube.stp';
let fileContent = fs.readFileSync (fileUrl);
let result = occt.ReadStepFile (fileContent);
console.log (result);
console.log (result.shapes);
});

0 comments on commit c545dbe

Please sign in to comment.