Skip to content
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

Merged
merged 3 commits into from Aug 4, 2021
Merged

Fix create instance line mesh #10807

merged 3 commits into from Aug 4, 2021

Conversation

sebavan
Copy link
Member

@sebavan sebavan commented Aug 4, 2021

@sebavan sebavan requested a review from Popov72 August 4, 2021 17:52
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const

if (this.instancedBuffers) {
instance.instancedBuffers = {};

for (var key in this.instancedBuffers) {
Copy link
Contributor

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];
Copy link
Contributor

@Popov72 Popov72 Aug 4, 2021

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.

Copy link
Member Author

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;
};

Copy link
Contributor

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!

@sebavan sebavan merged commit 4ad71b9 into BabylonJS:master Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants