Notes Specific to the Web Version

Updated: 01/18/2019

This page is for Cubism version 4.2 or earlier. Click here for the latest version.

Pass WebGL context, etc. to Renderer

To improve performance, CubismWebSamples refrains from using WebGL getters in the loop and passes them cached on the application side.
Frame buffer and viewport information must be passed to the renderer before drawing.

    // Pass the canvas size
    let viewport: number[] = [
        0, 
        0, 
        canvas.width,
        canvas.height
    ];

    this.getRenderer().setRenderState(frameBuffer, viewport);
    this.getRenderer().drawModel();

Allocator, Memory-Related Description

Unlike the Native version, variables and objects that are no longer needed are freed by garbage collection and must be properly dereferenced.

Texture Formats

The Web version requires UNPACK_PREMULTIPLY_ALPHA_WEBGL to be set to true when generating textures because the library’s drawing method is the Premultiplied method.

gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
Was this article helpful?
YesNo
Please let us know what you think about this article.