forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipeline.js
More file actions
123 lines (106 loc) · 3.33 KB
/
Copy pathPipeline.js
File metadata and controls
123 lines (106 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Provides methods used for setting the WebGL rendering pipeline of a Game Object.
*
* @namespace Phaser.GameObjects.Components.Pipeline
* @webglOnly
* @since 3.0.0
*/
var Pipeline = {
/**
* The initial WebGL pipeline of this Game Object.
*
* @name Phaser.GameObjects.Components.Pipeline#defaultPipeline
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
* @default null
* @webglOnly
* @since 3.0.0
*/
defaultPipeline: null,
/**
* The current WebGL pipeline of this Game Object.
*
* @name Phaser.GameObjects.Components.Pipeline#pipeline
* @type {Phaser.Renderer.WebGL.WebGLPipeline}
* @default null
* @webglOnly
* @since 3.0.0
*/
pipeline: null,
/**
* Sets the initial WebGL Pipeline of this Game Object.
* This should only be called during the instantiation of the Game Object.
*
* @method Phaser.GameObjects.Components.Pipeline#initPipeline
* @webglOnly
* @since 3.0.0
*
* @param {string} [pipelineName=TextureTintPipeline] - The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline.
*
* @return {boolean} `true` if the pipeline was set successfully, otherwise `false`.
*/
initPipeline: function (pipelineName)
{
if (pipelineName === undefined) { pipelineName = 'TextureTintPipeline'; }
var renderer = this.scene.sys.game.renderer;
if (renderer && renderer.gl && renderer.hasPipeline(pipelineName))
{
this.defaultPipeline = renderer.getPipeline(pipelineName);
this.pipeline = this.defaultPipeline;
return true;
}
return false;
},
/**
* Sets the active WebGL Pipeline of this Game Object.
*
* @method Phaser.GameObjects.Components.Pipeline#setPipeline
* @webglOnly
* @since 3.0.0
*
* @param {string} pipelineName - The name of the pipeline to set on this Game Object.
*
* @return {this} This Game Object instance.
*/
setPipeline: function (pipelineName)
{
var renderer = this.scene.sys.game.renderer;
if (renderer && renderer.gl && renderer.hasPipeline(pipelineName))
{
this.pipeline = renderer.getPipeline(pipelineName);
}
return this;
},
/**
* Resets the WebGL Pipeline of this Game Object back to the default it was created with.
*
* @method Phaser.GameObjects.Components.Pipeline#resetPipeline
* @webglOnly
* @since 3.0.0
*
* @return {boolean} `true` if the pipeline was set successfully, otherwise `false`.
*/
resetPipeline: function ()
{
this.pipeline = this.defaultPipeline;
return (this.pipeline !== null);
},
/**
* Gets the name of the WebGL Pipeline this Game Object is currently using.
*
* @method Phaser.GameObjects.Components.Pipeline#getPipelineName
* @webglOnly
* @since 3.0.0
*
* @return {string} The string-based name of the pipeline being used by this Game Object.
*/
getPipelineName: function ()
{
return this.pipeline.name;
}
};
module.exports = Pipeline;