Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Allow mesh as one vertex Geometry and multiple index Geometry's

#173

Currently SceneJS supports only one mesh per vertex list, and therefore does not allow multiple materials to be applied to different sections of the same mesh.

In other words, a material can only be applied to the entire mesh:

new SceneJS.Material({ ... },
    new SceneJS.Geometry({ 
        positions: [...],
        uv: [...],
        indices: [...]
    }));

This was discovered when parsing OBJ files that define material groups that cut across meshes. Although OBJ files can be converted to split meshes for material groups, this increases the file size considerably.

Solution

Allow a mesh to be constructed by multiple Geometry nodes, such that one supplies the positions and uv coords, while other child Geometry nodes each supply a portion of the indices. When a geometry is defined with positions but no indices, then child Geometry nodes are expected to supply the indices. Materials wrapping the child Geometry nodes will be applied to each of their face lists.

new SceneJS.Geometry({ 
   positions: [...],
   uv: [...]
},

    new SceneJS.Material({ baseColor: { r: 1 } },
        new SceneJS.Geometry({ 
            indices: [...],
            primitive: "triangles"
        })),

    new SceneJS.Material({ baseColor: { g: 1 } },
        new SceneJS.Geometry({ 
            indices: [...],
            primitive: "triangles"
        })
    )
);

Plays well with BoundingBox nodes

We'll be able to wrap the face sections with BoundingBox's

new SceneJS.Geometry({ 
   positions: [...],
   uv: [...]
},

    new SceneJS.BoundingBox({ ... extents of first set of faces.... }, 
        new SceneJS.Material({ baseColor: { r: 1 } },
            new SceneJS.Geometry({ 
                indices: [...],
                primitive: "triangles"
            }))),

    new SceneJS.BoundingBox({ ... extents of second set of faces.... }, 
        new SceneJS.Material({ baseColor: { g: 1 } },
            new SceneJS.Geometry({ 
                indices: [...],
                primitive: "triangles"
            })))
);

Addition benefit

  • This will allow more speed in static scenes where the vertices for everything can be bound in one operation.
  • Will support OBJ multi materials

Reported by lindsay.kay (at xeolabs) · September 15th, 2010 @ 08:39 AM

State: resolved
Milestone: V0.7.8

Activity

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.