-
Notifications
You must be signed in to change notification settings - Fork 137
Editor scene #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor scene #438
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #438 +/- ##
==========================================
- Coverage 89.74% 89.70% -0.04%
==========================================
Files 35 35
Lines 4201 4237 +36
==========================================
+ Hits 3770 3801 +31
- Misses 431 436 +5
☔ View full report in Codecov by Sentry. |
This reverts commit 8769d7a.
build/bindings/wasm/manifold.d.ts | ||
build/bindings/wasm/manifold-global-types.d.ts | ||
build/bindings/wasm/manifold-encapsulated-types.d.ts | ||
path: bindings/wasm/examples/dist/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's now more to deploy, but it's simpler.
@@ -12,12 +12,14 @@ | |||
// See the License for the specific language governing permissions and | |||
// limitations under the License. | |||
|
|||
import {examples} from './examples.js'; | |||
const exampleFunctions = examples.functionBodies; | |||
import ManifoldWorker from './worker?worker'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting new Vite syntax.
@@ -144,6 +155,28 @@ export function writeMesh(doc, manifoldMesh, attributes, materials) { | |||
const buffer = doc.getRoot().listBuffers()[0]; | |||
const manifoldExtension = doc.createExtension(EXTManifold); | |||
|
|||
const attributeUnion = []; | |||
for (const matAttributes of attributes) { | |||
matAttributes.forEach((attribute, i) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input attributes
is now a string[][]
instead of string[]
, since different materials can have different attributes.
bindings/wasm/examples/package.json
Outdated
@@ -0,0 +1,30 @@ | |||
{ | |||
"name": "vite-starter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should change this.
// Use GLTFNode for disjoint manifolds rather than compose(), as this will | ||
// keep them better organized in the GLB. This will also allow you to | ||
// specify material properties, and even vertex colors via | ||
// setProperties(). See Tetrahedron Puzzle example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the interesting part!
// unlit = false, | ||
// name = '' | ||
// } | ||
const node = new GLTFNode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good example of what's possible with this new API, plus it's pretty.
[(k + i - j) * size, (k - i) * size, (-j) * size]; | ||
node.material = { | ||
baseColorFactor: | ||
[(k + i - j + 1) / m, (k - i + 1) / m, (j + 1) / m] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows how you can reuse the same manifold many times, even with different materials, but just a single one gets packed in the GLB and referenced appropriately.
} | ||
const attributes = []; | ||
const materials = []; | ||
const manifoldMesh = readMesh(mesh, attributes, materials); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our JS testing is now giving us dramatically more coverage - we're using the worker directly instead of duplicating its functionality, which means we're also round-tripping every test through write-GLB and read-GLB now.
@@ -207,7 +207,7 @@ class Manifold { | |||
Manifold Mirror(glm::vec3) const; | |||
Manifold Warp(std::function<void(glm::vec3&)>) const; | |||
Manifold SetProperties( | |||
int, std::function<void(glm::vec3, const float*, float*)>) const; | |||
int, std::function<void(float*, glm::vec3, const float*)>) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched the order here because I forgot to follow my own style of putting output arguments before input arguments.
Ah nice, no more of that exporting mess in |
@elalish I've rebased the WIP bindings onto this branch, but now I'm not sure what the invocation is for running the tests (should I be using the worker one, I noticed that edit: installing |
Yeah, sorry I need to update the README. Basically everything is run from the |
* SetProperties working * cleanup * added Node * switched to Vite * scene export working * vertex color output works * added unlit * fixed rename bug * switch worker to TS * don't fail on empty manifolds * reusing meshes * cleanup, updated gyroid example * change signature of setPropFunc * updated examples * add dist for githack testing * Revert "add dist for githack testing" This reverts commit 8769d7a. * remove duplicate files * updated docs * fixed some bugs * multi-material working * switched to vitest * tests pass * fixed examples * fix CI * update deployment * tweak logging * cleanup * fix copy * updated READMEs * extend timeout
Fixes #431
This adds
GLTFNode
andGLTFMaterial
to ManifoldCAD.org, which gives us some pretty huge new capabilities. We can now easily create entire scene hierarchies and export them to GLB, all while avoiding duplication of the underlying mesh data if you reference a manifold several times. You can change material properties on any node - they act like CSS where it applies to everything underneath, but is overridden by anything specified lower down. Since specifying parents is only possible during node construction/cloning I believe it's impossible to construct a scene that's not a tree.It started to get complex enough that I took @donmccurdy's advice and switched our editor (and examples) over to Vite. It's a pretty nice build system and we don't have to worry about import maps anymore. It also makes mixing JS and TS very easy, so I took the liberty of switching our worker over to TS, which was very helpful in development. I'll probably transition the rest of the editor to TS soon.
There's not a very clean way to use raw.githack with Vite, and I'm not a huge fan of checking in builds anyway, so I'm going to abandon this for now.