Sign in to follow this  
Hersir

Shadow generator and TransformNode

Recommended Posts

Hi,

I use TransformNode as parent for my meshes and would like to add all children to ShadowGenerator, like this `addShadowCaster(node, true)` but it accepts just AbstractMesh as input there, what about changing type to TransformNode ?

Like this:

 public addShadowCaster(mesh: TransformNode, includeDescendants = true): ShadowGenerator {
            if (!this._shadowMap) {
                return this;
            }

            if (!this._shadowMap.renderList) {
                this._shadowMap.renderList = [];
            }
            // Need to check if is real mesh
            if (mesh instanceof AbstractMesh) {
                this._shadowMap.renderList.push(mesh);
            }
            if (includeDescendants) {
                this._shadowMap.renderList.push(...mesh.getChildMeshes());
            }

            return this;
        }

for `removeShadowCaster` similar

public removeShadowCaster(mesh: TransformNode, includeDescendants = true): ShadowGenerator {
            if (!this._shadowMap || !this._shadowMap.renderList) {
                return this;
            }
            // check if real mesh
            if (mesh instanceof AbstractMesh) {
                var index = this._shadowMap.renderList.indexOf(mesh);

                if (index !== -1) {
                    this._shadowMap.renderList.splice(index, 1);
                }
            }

            if (includeDescendants) {
                // use getChildMeshes instead of getChildren to support nested TransformNodes
                for (var child of mesh.getChildMeshes(true)) {
                    this.removeShadowCaster(<any>child);
                }
            }

            return this;
        }

Any objections on this ? I haven't tested / profiled change impact so its just an idea now :)

Would like to hear feedback, as maybe I am missing something here :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.