threeify icon indicating copy to clipboard operation
threeify copied to clipboard

Repo structure

Open Astrak opened this issue 5 years ago • 7 comments

Some thoughts: @bhouston you mentioned that you'd like this project to be able to talk to webgl2 as well as webgpu. Others might even like webgl1. I think it's a good opportunity to make it modular: have the math stuff as a module, a module for the renderer API, one for the material API, and then one module with webgl2 (actual renderer+shaders), same for webgpu... We could have a module for orbit controls then etc. This would turn the structure into the trendy lerna monorepo thing. The big advantage is that it would make the project the more friendly to use and let people transition across webgl1/2/webgpu. The code could look something like:

import { Vector3 } from "@threeify/maths";
import { Box } from "@threeify/geometries";
import { Mesh, Scene } from "@threeify/scene-graph";
import { Renderer } from "@threeify/renderer";
import { PBRMaterial } from "@threeify/materials";
import { webgl2 } from "@threeify/webgl2";

const renderer = new Renderer(webgl2);
const material = new PBRMaterial();
const geometry = new Box();
const mesh = new Mesh({ geometry, material });

TODO: Benchmark how PlayCanvas and Babylon did their webgl2 and webgpu demos from their existing library stack

Astrak avatar Jun 10 '20 12:06 Astrak

Can we could also likely make the threeify-glsl-transpiler a module in the same spirit. I do like that structure. Let's do it.

bhouston avatar Jun 10 '20 12:06 bhouston

We could just adopt Yarn2 instead of Lerna. I understand this is preferred.

A popular recipe for setting up monorepo for JavScript projects is the combination of Yarn’s workspaces (existed since Yarn 1) and Lerna as a project manager.

The good news with Yarn 2 is that now, Yarn doubles as being both a package manager as well as a project manager and aims to provide a wholesome experience for running monorepos smoothly.

https://snyk.io/blog/yarn-2-intro/

More details:

https://dev.to/lampewebdev/node-on-rails-creating-a-monorepo-aka-workspaces-with-yarn-284i

bhouston avatar Jun 10 '20 15:06 bhouston

I've asked for input on Twitter here: https://twitter.com/BenHouston3D/status/1270750233316798467

bhouston avatar Jun 10 '20 16:06 bhouston

Yes I wanted to make a case for yarn for another reason, but it's a better tool indeed

Astrak avatar Jun 10 '20 16:06 Astrak

Lena works with yarn workspaces also, so we can use both together

Astrak avatar Jun 10 '20 16:06 Astrak

Internally we are just using Yarn2. My recommendation is to lets get this working as a rendering engine before going modular. I just want to ensure that we can get provable results from the project before refactoring it.

bhouston avatar Jun 15 '20 21:06 bhouston

BTW I was able to get "@threeify/" modules resolution working in the /examples folder via just tsconfig.json settings. Using this approach:

https://stackoverflow.com/a/43330003

bhouston avatar Jun 15 '20 21:06 bhouston

I've adopted a mono-repository format.

bhouston avatar Jan 26 '23 21:01 bhouston