Skip to content

tristrips not working because MESH_PARAMETERS not defined for it #79

Closed
@j4yk

Description

@j4yk

I am currently investigating XML3D as an export option for a 3D graphics application. For prototyping I generated the following xml3d:

    <xml3d xmlns="http://www.xml3d.org/2009/xml3d">
        <view position="0 0 1"/>
        <shader id="mapShader" script="urn:xml3d:shader:flat">
            <bool name="useVertexColor">true</bool>
        </shader>
        <mesh type="tristrips" shader="#mapShader">
            <int name="index">0 6 4 5 0 <!-- etc. --></int>
            <float3 name="position">-0.5 -0.5 -0.025 -0.5 -0.5 0.025 -0.5 0.5 -0.025 -0.5 0.5 0.025 0.5 -0.5 -0.025 0.5 -0.5 0.025 0.5 0.5 -0.025 0.5 0.5 0.025 0.155431 0.156691 0.025 0.155431 0.156691 0.075 0.155431 0.357603 <!-- etc --> </float3>
            <float3 name="color">0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 <!-- etc --></float3>
        </mesh>
    </xml3d>

Without a little modification in xml3d.js this will not work in Chrome, however. For gl.TRIANGLE_STRIP no MESH_PARAMETERS are defined which leads to the following error in Chrome:

Unsupported Mesh request: GLMesh {context: GLContext, glType: 5, buffers: Object, uniformOverride: Object, minIndex: 0…} 5

...and subsequently errors of the type Cannot read property ... of null.

These lines are in xml3d.js but leave out triangle strips:

MESH_PARAMETERS[WebGLRenderingContext.TRIANGLES] = {
    attributeData: {"position": Xflow.DATA_TYPE.FLOAT3 },
    typeData: {
        "index": Xflow.DATA_TYPE.INT,
        "solid": Xflow.DATA_TYPE.BOOL,
        "vertexCount": Xflow.DATA_TYPE.INT
    },
    bboxFix: {
        "boundingBox" : Xflow.DATA_TYPE.FLOAT3
    },
    bboxCompute: {
        "position" : Xflow.DATA_TYPE.FLOAT3
    } };
MESH_PARAMETERS[WebGLRenderingContext.LINE_STRIP] = MESH_PARAMETERS[WebGLRenderingContext.TRIANGLES];
MESH_PARAMETERS[WebGLRenderingContext.LINES] = MESH_PARAMETERS[WebGLRenderingContext.TRIANGLES];
MESH_PARAMETERS[WebGLRenderingContext.POINTS] = MESH_PARAMETERS[WebGLRenderingContext.TRIANGLES];

adding this line seems to solve my problem:

MESH_PARAMETERS[WebGLRenderingContext.TRIANGLE_STRIP] = MESH_PARAMETERS[WebGLRenderingContext.TRIANGLES];

Can you tell me if triangle strips were left out there by intention or if they have just been forgotten?

Minimal example:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script src="http://www.xml3d.org/xml3d/script/xml3d.js" type="text/javascript"/>
        <script src="http://www.xml3d.org/xml3d/script/tools/camera.js" type="text/javascript"/>
    </head>
    <body>
        <xml3d xmlns="http://www.xml3d.org/2009/xml3d">
            <view position="0 0 1"/>
            <mesh type="tristrips">
                <int name="index">0 1 2 3</int>
                <float3 name="position">
                -1 -1 0
                 1 -1 0
                -1  1 0
                 1  1 0
                 </float3>
            </mesh>
        </xml3d>
    </body>
</html>

I would expect a rectangle but get the above error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions