-
Notifications
You must be signed in to change notification settings - Fork 57
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
improve InstancedMesh so that it grows buffers directly instead of replacing THREE.InstancedMesh #273
Comments
When the count is bigger than the previous allotted space, more space needs to be made, and right now the simple way to do that is to re-create the underlying Here's a solution to use as a consumer of Lume: const geometry = new THREE.RingGeometry(1.75, 2, 32)
// Any time the count changes, put back the same geometry
createEffect(() => {
instancedMesh.count
instancedMesh.three.geometry = geometry
}) Something we can do inside Lume is improve lume-instanced-mesh so that instead of it creating a new We should also look at is making it as easy as possible to implement new behaviors with custom geometries/materials, so that the underlying THREE resources will be managed in the Lume life cycles. Here's the thing we'd want to update directly inside of https://github.com/mrdoob/three.js/blob/master/src/objects/InstancedMesh.js#L25 We'd need to make a new We can update Lume's The https://github.com/lume/lume/blob/develop/src/meshes/InstancedMesh.ts#L160-L189 It is reactive, so if there's anything inside of One main thing is that, this is all for the ideal purpose of the HTML API and everything about it being always correct. I.e. if someone changes the HTML/DOM, the rendering should always be correct. Accessing We should of course try to improve it however we can on both sides:
As an example, it currently isn't too much work to create a new geometry behavior: But we can think about how to make it easier. I also want to move away from behaviors for some things like geometries and materials (though they may be useful for other things that are less declarative), and instead make them custom elements that have simpler class/type definitions and that are easier to maintain (later the improved static types will be easier to compile to WebAssembly with ByteScript). The new way can look something like this: <lume-mesh>
<!-- these are not scene graph nodes, but they will manage certain sub-object on the parent element instances (f.e. .geometry or .material of the .three instance), similar to behaviors but wired up differently: -->
<lume-box-geometry wireframe></lume-box-geometry>
<lume-phong-material color="pink"></lume-phong-material>
<!-- ... scene graph node as usual ... -->
</lume-mesh> With this approach the attributes for all elements are known up front with static type definitions. Right now behaviors can add any numbers of attributes and JS properties to their host mesh, which is not very easy to keep type safe or to add new types for. A user can currently make a new behavior for that can be applied onto meshes, but there is no easy way to ensure any new properties are part of the lume-mesh type definition, plus we don't want lume-mesh to become a bag of arbitrary property definitions. So, instead, each of these new types of elements will have their own static type definition and will not modify the parent element's types, and users can easily define property types simply by making them part of their new subclass definition. We could then also have something like a <lume-mesh>
<lume-custom-geometry id="geo"></lume-custom-geometry>
<lume-phong-material color="pink"></lume-phong-material>
<!-- ... scene graph node as usual ... -->
</lume-mesh>
<script>
const geo = document.querySelector('#geo')
geo.wireframe = true
geo.threeGeometry = new SomeSpecialGeometry(...)
</script> or something, to easily provide Threejs geometries/materials without making a new wrapper (actually that might be a base class for new wrappers to extend from). This is now getting fairly threejs specific with such an element, so I'm also thinking maybe naming it Later on we'll have Babylon.js- and PlayCanvas-backed implementations of Lume so people can choose their underlying engine. I'd like to eventually have our own rendering impl too. Probably starting as our fork of Three.js, but we'll probably really do this later once we have resources for it. Anyway, that got a little side-tracked, but TLDR: let's make it really easy to add new wrappers for things like custom geometries and materials. |
The most ideal solution would be making a new GeometryBehavior like It is pretty simple, and it maps any properties specific to that geometry as needed. Would be great to add more geometries to Lume. |
@keywizzle on asked on Discord:
The text was updated successfully, but these errors were encountered: