#173 ✓resolved
lindsay.kay (at xeolabs)

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

Reported by lindsay.kay (at xeolabs) | September 15th, 2010 @ 08:39 AM | in V0.7.8

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

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

SceneJS provides easy access to WebGL through a simple and declarative JavaScript API. The SceneJS API is functional, which enables its scene definitions to be really compact and expressive, while hooking into other JavaScript code just that little bit more smoothly.

Shared Ticket Bins

People watching this ticket

Tags

Referenced by

Pages