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
Fix create instance line mesh #10807
Conversation
src/Meshes/linesMesh.ts
Outdated
@@ -263,7 +263,17 @@ export class LinesMesh extends Mesh { | |||
* @returns a new InstancedLinesMesh | |||
*/ | |||
public createInstance(name: string): InstancedLinesMesh { | |||
return new InstancedLinesMesh(name, this); | |||
let instance = new InstancedLinesMesh(name, this); |
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.
nit: const
src/Meshes/linesMesh.ts
Outdated
if (this.instancedBuffers) { | ||
instance.instancedBuffers = {}; | ||
|
||
for (var key in this.instancedBuffers) { |
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.
nit: const
instance.instancedBuffers = {}; | ||
|
||
for (var key in this.instancedBuffers) { | ||
instance.instancedBuffers[key] = this.instancedBuffers[key]; |
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 think you should set it to null
instead, as it is done in Mesh.registerInstancedBuffer
. Else the instance will use the same attributes than the master.
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.
It is actually a copy paste from instancedMeshFactory :-)
Mesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {
let instance = new InstancedMesh(name, mesh);
if (mesh.instancedBuffers) {
instance.instancedBuffers = {};
for (var key in mesh.instancedBuffers) {
instance.instancedBuffers[key] = mesh.instancedBuffers[key];
}
}
return instance;
};
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.
Ok, my mistake, I thought instancedBuffers
were vertex buffers but they are custom data instead, that can be overwritten afterward by the user!
https://forum.babylonjs.com/t/instance-color-alpha-for-linesmesh/22812