Skip to content

Commit

Permalink
Merge pull request #13 from ThatOpen/feat/restructure-clay
Browse files Browse the repository at this point in the history
Feat/restructure clay
  • Loading branch information
agviegas authored Feb 28, 2024
2 parents 2b5d36b + c728dff commit 16a9b11
Show file tree
Hide file tree
Showing 44 changed files with 80,130 additions and 22,446 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ module.exports = {
sourceType: "module",
},
plugins: ["@typescript-eslint", "prettier"],
ignorePatterns: ["**/dist/*", "**/node_modules/*", "**/*.json", "**/*.js"],
ignorePatterns: [
"**/dist/*",
"**/node_modules/*",
"**/*.json",
"**/flatbuffers/*",
],
rules: {
"prettier/prettier": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ body:
options:
- label: Read the [docs](https://docs.thatopen.com/intro).
required: true
- label: Check that there isn't [already an issue](https://github.com/IFCjs/clay/issues) that reports the same bug to avoid creating a duplicate.
- label: Check that there isn't [already an issue](https://github.com/ThatOpen/engine_clay/issues) that reports the same bug to avoid creating a duplicate.
required: true
- label: Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to [mrdoob/threejs](https://github.com/mrdoob/three.js) instead.
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ body:
options:
- label: Read the [docs](https://docs.thatopen.com/intro).
required: true
- label: Check that there isn't [already an issue](https://github.com/IFCjs/clay/issues) that requests the same feature to avoid creating a duplicate.
- label: Check that there isn't [already an issue](https://github.com/ThatOpen/engine_clay/issues) that requests the same feature to avoid creating a duplicate.
required: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down Expand Up @@ -128,4 +129,3 @@ out
.yarn/install-state.gz
.pnp.*
.idea/
dist/
8 changes: 4 additions & 4 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

72 changes: 64 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,78 @@
|
<a href="https://people.thatopen.com/">community</a>
|
<a href="https://www.npmjs.com/package/openbim-clay">npm package</a>
<a href="https://www.npmjs.com/package/bim-fragment">npm package</a>
</p>

![cover](resources/cover.png)

<h1>Clay <img src="https://ifcjs.github.io/components/resources/favicon.ico" width="32"></h1>
<h1>BIM Fragment <img src="https://thatopen.github.io/engine_components/resources/favicon.ico" width="32"></h1>

[![NPM Package][npm]][npm-url]
[![NPM Package][npm-downloads]][npm-url]
[![Tests](https://github.com/IFCjs/components/actions/workflows/tests.yml/badge.svg)](https://github.com/IFCjs/components/actions/workflows/tests.yaml)
[![Tests](https://github.com/ThatOpen/engine_components/actions/workflows/tests.yml/badge.svg)](https://github.com/ThatOpen/engine_components/actions/workflows/tests.yaml)

This library is a BIM geometry kernel and modeller built on top of [Three.js](https://github.com/mrdoob/three.js/). It's specifically designed to create BIM applications that require the generation / edition of geometries and/or to expose 3D modellers to end users.
This library is a geometric system to efficiently display 3D BIM data built on top of [Three.js](https://github.com/mrdoob/three.js/). Specifically, it uses [InstancedMeshes](https://threejs.org/docs/#api/en/objects/InstancedMesh) to draw each set of repeated geometries (which are abundant in BIM models) using a single draw call.

It's a work in progress and the API might be unstable.
- It uses [flatbuffers](https://flatbuffers.dev/) to persist data as a binary format efficiently.
- It prevents [memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects) exposing a `dispose()` method.

You generally won't need to interact with this library direclty. Instead, you can use [components](https://github.com/ThatOpen/engine_components), which provides an abstraction layer of tools that use this format and make the creation of BIM tools very easy.

[npm]: https://img.shields.io/npm/v/openbim-clay
[npm-url]: https://www.npmjs.com/package/openbim-clay
[npm-downloads]: https://img.shields.io/npm/dw/openbim-clay
### Usage

You need to be familiar with [Three.js API](https://github.com/mrdoob/three.js/) to be able to use this library effectively. In the following example, we will create a cube in a 3D scene that can be navigated with the mouse or touch events. You can see the full example [here](https://github.com/ThatOpen/engine_components/blob/main/src/core/SimpleScene/index.html) and the deployed app [here](https://thatopen.github.io/engine_components/src/core/SimpleScene/index.html).

```js
import * as FRAGS from 'bim-fragment';

const canvas = document.getElementById('container');

// Simple three.js scene: check the resources folder of this repo
const threeScene = new SimpleThreeScene(canvas);

let chairs;

const serializer = new FRAGS.Serializer();

async function importChairsBinary() {
if (chairs !== undefined) return;
const fetched = await fetch("../resources/chairs.frag");
const rawData = await fetched.arrayBuffer();
const buffer = new Uint8Array(rawData);
chairs = serializer.import(buffer);

for(const frag of chairs) {
threeScene.scene.add(frag.mesh);
}
}

function deleteChairs() {
if (!chairs) return;
for(const frag of chairs) {
frag.dispose(true);
}
chairs = undefined;
}

async function exportChairsBinary() {
if (!chairs) return;

const buffer = serializer.export(chairs);
const file = new File([new Blob([buffer])], "chairs.frag");
const link = document.createElement('a');
document.body.appendChild(link);

link.download = 'chairs.frag';
link.href = URL.createObjectURL(file);
link.click();

link.remove();
}
```



[npm]: https://img.shields.io/npm/v/bim-fragment
[npm-url]: https://www.npmjs.com/package/bim-fragment
[npm-downloads]: https://img.shields.io/npm/dw/bim-fragment
57 changes: 42 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
{
"name": "openbim-clay",
"main": "index.js",
"version": "0.0.5",
"author": "antonio gonzalez viegas, quim moya",
"license": "MIT",
"packageManager": "yarn@3.2.1",
"description": "3D BIM Modelling API",
"main": "src/index.js",
"scripts": {
"test": "jest",
"build": "yarn clean && tsc && yarn build-examples",
"build": "tsc && yarn build-examples",
"build-examples": "rollup -c resources/rollup.config.mjs",
"clean": "node resources/cleaner.mjs",
"publish-repo": "cpy package.json dist && cd dist && npm publish",
"publish-repo": "tsc && cpy package.json dist && cd dist && npm publish",
"publish-repo-alpha": "cpy package.json dist && cd dist && npm publish --tag alpha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ThatOpen/engine_clay.git"
},
"keywords": [
"ifc",
"geometry",
"threejs",
"bim",
"3d"
],
"author": "agviegas",
"license": "MIT",
"bugs": {
"url": "https://github.com/ThatOpen/engine_fragment/issues"
},
"homepage": "https://github.com/ThatOpen/engine_fragment",
"dependencies": {
"earcut": "^2.2.4",
"three-mesh-bvh": "0.7.0",
"uuid": "^9.0.1"
},
"peerDependencies": {
"three": "^0.160.1",
"web-ifc": "^0.0.51"
},
"devDependencies": {
"@rollup/plugin-commonjs": "25.0.0",
"@rollup/plugin-node-resolve": "15.1.0",
"@types/earcut": "^2.1.1",
"@types/earcut": "2.1.4",
"@types/jest": "27.0.0",
"@types/node": "^14.14.31",
"@types/three": "0.152.1",
"@types/three": "^0.160.0",
"@types/uuid": "9.0.8",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"cpy-cli": "^3.1.1",
Expand All @@ -28,15 +52,18 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"jest": "27.0.4",
"jest": "^27.0.4",
"prettier": "^2.3.1",
"rollup": "3.2.3",
"rollup": "^3.2.3",
"three": "^0.160.1",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typescript": "^4.3.2"
"typescript": "^4.3.2",
"web-ifc": "0.0.51"
},
"dependencies": {
"earcut": "^2.2.4",
"three": "0.152.2"
"browser": {
"crypto": false,
"fs": false,
"path": false
}
}
Binary file modified resources/favicon.ico
Binary file not shown.
Loading

0 comments on commit 16a9b11

Please sign in to comment.