MCPcopy Create free account
hub / github.com/melonjs/melonJS / init

Method init

packages/spine-plugin/src/SpineBatcher.js:31–86  ·  view source on GitHub ↗

* Initialize (or re-initialize) the batcher. * Settings are built here rather than in the constructor so the * renderer's context-restore recovery can re-create all GPU * resources with a bare `batcher.init(renderer)` call, matching * the engine's built-in batchers. * @param {WebGLRenderer

(renderer)

Source from the content-addressed store, hash-verified

29 * @ignore
30 */
31 init(renderer) {
32 // create the official Spine two-color shader and extract its source
33 const spineShader = Shader.newTwoColoredTextured(
34 getManagedContext(renderer.getCanvas()),
35 );
36 const shaderSource = {
37 vertex: spineShader.getVertexShaderSource(),
38 fragment: spineShader.getFragmentSource(),
39 };
40 spineShader.dispose();
41
42 // Spine vertex layout: a_position(2) + a_color(4) + a_texCoords(2) + a_color2(4)
43 super.init(renderer, {
44 attributes: [
45 {
46 name: Shader.POSITION,
47 size: 2,
48 type: renderer.gl.FLOAT,
49 normalized: false,
50 offset: 0 * Float32Array.BYTES_PER_ELEMENT,
51 },
52 {
53 name: Shader.COLOR,
54 size: 4,
55 type: renderer.gl.FLOAT,
56 normalized: false,
57 offset: 2 * Float32Array.BYTES_PER_ELEMENT,
58 },
59 {
60 name: Shader.TEXCOORDS,
61 size: 2,
62 type: renderer.gl.FLOAT,
63 normalized: false,
64 offset: 6 * Float32Array.BYTES_PER_ELEMENT,
65 },
66 {
67 name: Shader.COLOR2,
68 size: 4,
69 type: renderer.gl.FLOAT,
70 normalized: false,
71 offset: 8 * Float32Array.BYTES_PER_ELEMENT,
72 },
73 ],
74 shader: shaderSource,
75 maxVertices: 10920,
76 indexed: true,
77 projectionUniform: Shader.MVP_MATRIX,
78 });
79
80 /**
81 * the current texture bound to the batcher
82 * @type {object|null}
83 * @ignore
84 */
85 this.lastTexture = null;
86 }
87
88 /**

Callers

nothing calls this directly

Calls 4

getManagedContextFunction · 0.90
getCanvasMethod · 0.80
initMethod · 0.65
disposeMethod · 0.45

Tested by

no test coverage detected