pixi_projection 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pixi_projection.rb +8 -0
- data/lib/pixi_projection/version.rb +3 -0
- data/pixi_projection.gemspec +30 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/.keep +0 -0
- data/vendor/assets/javascripts/pixi-projection-spine.js +3987 -0
- data/vendor/assets/javascripts/pixi-projection-spine.js.map +1 -0
- data/vendor/assets/javascripts/pixi-projection.js +3931 -0
- data/vendor/assets/javascripts/pixi-projection.js.map +1 -0
- data/vendor/assets/stylesheets/.keep +0 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c0cd5c506175c361ed5f172206946badfefea22c53843ade35f7c5d2c32a11a
|
4
|
+
data.tar.gz: 7351a37fd7b9b0d2895aba5819bef630c31e144069831a67a990ea1f93f9b5bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58664c331237b0c496647868fdfa1fe39505ba821d7b3147589dedc5f2df8463a7e65ef07818fdc4392e0f3d269683708fd4b03cea806a2f826666a2b0f7b269
|
7
|
+
data.tar.gz: 201820611cbaaa3a907602ba81420aaa6aa3fa6a398e6ec08ed5973698ae77b2c031235443774b549975a34537683134bb53874f27824399cf6117d125b5786f
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Chris Palmweaver
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# PixiProjection
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pixi_projection`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'pixi_projection'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pixi_projection
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pixi_projection.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pixi_projection"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "pixi_projection/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pixi_projection"
|
8
|
+
spec.version = PixiProjection::VERSION
|
9
|
+
spec.authors = ["Chris Scalf"]
|
10
|
+
spec.email = ["shrewdpixeldesign@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A gem for importing the pixi_projection.js canvas library into Rails projects.}
|
13
|
+
spec.description = %q{Technically requires spine2d, and will throw a TypeError error without it.}
|
14
|
+
spec.homepage = "https://github.com/Palmweaver/pixi_projection"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
end
|
data/vendor/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,3987 @@
|
|
1
|
+
var pixi_projection;
|
2
|
+
(function (pixi_projection) {
|
3
|
+
var utils;
|
4
|
+
(function (utils) {
|
5
|
+
function createIndicesForQuads(size) {
|
6
|
+
var totalIndices = size * 6;
|
7
|
+
var indices = new Uint16Array(totalIndices);
|
8
|
+
for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) {
|
9
|
+
indices[i + 0] = j + 0;
|
10
|
+
indices[i + 1] = j + 1;
|
11
|
+
indices[i + 2] = j + 2;
|
12
|
+
indices[i + 3] = j + 0;
|
13
|
+
indices[i + 4] = j + 2;
|
14
|
+
indices[i + 5] = j + 3;
|
15
|
+
}
|
16
|
+
return indices;
|
17
|
+
}
|
18
|
+
utils.createIndicesForQuads = createIndicesForQuads;
|
19
|
+
function isPow2(v) {
|
20
|
+
return !(v & (v - 1)) && (!!v);
|
21
|
+
}
|
22
|
+
utils.isPow2 = isPow2;
|
23
|
+
function nextPow2(v) {
|
24
|
+
v += +(v === 0);
|
25
|
+
--v;
|
26
|
+
v |= v >>> 1;
|
27
|
+
v |= v >>> 2;
|
28
|
+
v |= v >>> 4;
|
29
|
+
v |= v >>> 8;
|
30
|
+
v |= v >>> 16;
|
31
|
+
return v + 1;
|
32
|
+
}
|
33
|
+
utils.nextPow2 = nextPow2;
|
34
|
+
function log2(v) {
|
35
|
+
var r, shift;
|
36
|
+
r = +(v > 0xFFFF) << 4;
|
37
|
+
v >>>= r;
|
38
|
+
shift = +(v > 0xFF) << 3;
|
39
|
+
v >>>= shift;
|
40
|
+
r |= shift;
|
41
|
+
shift = +(v > 0xF) << 2;
|
42
|
+
v >>>= shift;
|
43
|
+
r |= shift;
|
44
|
+
shift = +(v > 0x3) << 1;
|
45
|
+
v >>>= shift;
|
46
|
+
r |= shift;
|
47
|
+
return r | (v >> 1);
|
48
|
+
}
|
49
|
+
utils.log2 = log2;
|
50
|
+
function getIntersectionFactor(p1, p2, p3, p4, out) {
|
51
|
+
var A1 = p2.x - p1.x, B1 = p3.x - p4.x, C1 = p3.x - p1.x;
|
52
|
+
var A2 = p2.y - p1.y, B2 = p3.y - p4.y, C2 = p3.y - p1.y;
|
53
|
+
var D = A1 * B2 - A2 * B1;
|
54
|
+
if (Math.abs(D) < 1e-7) {
|
55
|
+
out.x = A1;
|
56
|
+
out.y = A2;
|
57
|
+
return 0;
|
58
|
+
}
|
59
|
+
var T = C1 * B2 - C2 * B1;
|
60
|
+
var U = A1 * C2 - A2 * C1;
|
61
|
+
var t = T / D, u = U / D;
|
62
|
+
if (u < (1e-6) || u - 1 > -1e-6) {
|
63
|
+
return -1;
|
64
|
+
}
|
65
|
+
out.x = p1.x + t * (p2.x - p1.x);
|
66
|
+
out.y = p1.y + t * (p2.y - p1.y);
|
67
|
+
return 1;
|
68
|
+
}
|
69
|
+
utils.getIntersectionFactor = getIntersectionFactor;
|
70
|
+
function getPositionFromQuad(p, anchor, out) {
|
71
|
+
out = out || new PIXI.Point();
|
72
|
+
var a1 = 1.0 - anchor.x, a2 = 1.0 - a1;
|
73
|
+
var b1 = 1.0 - anchor.y, b2 = 1.0 - b1;
|
74
|
+
out.x = (p[0].x * a1 + p[1].x * a2) * b1 + (p[3].x * a1 + p[2].x * a2) * b2;
|
75
|
+
out.y = (p[0].y * a1 + p[1].y * a2) * b1 + (p[3].y * a1 + p[2].y * a2) * b2;
|
76
|
+
return out;
|
77
|
+
}
|
78
|
+
utils.getPositionFromQuad = getPositionFromQuad;
|
79
|
+
})(utils = pixi_projection.utils || (pixi_projection.utils = {}));
|
80
|
+
})(pixi_projection || (pixi_projection = {}));
|
81
|
+
PIXI.projection = pixi_projection;
|
82
|
+
var pixi_projection;
|
83
|
+
(function (pixi_projection) {
|
84
|
+
var AbstractProjection = (function () {
|
85
|
+
function AbstractProjection(legacy, enable) {
|
86
|
+
if (enable === void 0) { enable = true; }
|
87
|
+
this._enabled = false;
|
88
|
+
this.legacy = legacy;
|
89
|
+
if (enable) {
|
90
|
+
this.enabled = true;
|
91
|
+
}
|
92
|
+
this.legacy.proj = this;
|
93
|
+
}
|
94
|
+
Object.defineProperty(AbstractProjection.prototype, "enabled", {
|
95
|
+
get: function () {
|
96
|
+
return this._enabled;
|
97
|
+
},
|
98
|
+
set: function (value) {
|
99
|
+
this._enabled = value;
|
100
|
+
},
|
101
|
+
enumerable: true,
|
102
|
+
configurable: true
|
103
|
+
});
|
104
|
+
AbstractProjection.prototype.clear = function () {
|
105
|
+
};
|
106
|
+
return AbstractProjection;
|
107
|
+
}());
|
108
|
+
pixi_projection.AbstractProjection = AbstractProjection;
|
109
|
+
var TRANSFORM_STEP;
|
110
|
+
(function (TRANSFORM_STEP) {
|
111
|
+
TRANSFORM_STEP[TRANSFORM_STEP["NONE"] = 0] = "NONE";
|
112
|
+
TRANSFORM_STEP[TRANSFORM_STEP["BEFORE_PROJ"] = 4] = "BEFORE_PROJ";
|
113
|
+
TRANSFORM_STEP[TRANSFORM_STEP["PROJ"] = 5] = "PROJ";
|
114
|
+
TRANSFORM_STEP[TRANSFORM_STEP["ALL"] = 9] = "ALL";
|
115
|
+
})(TRANSFORM_STEP = pixi_projection.TRANSFORM_STEP || (pixi_projection.TRANSFORM_STEP = {}));
|
116
|
+
})(pixi_projection || (pixi_projection = {}));
|
117
|
+
var __extends = (this && this.__extends) || (function () {
|
118
|
+
var extendStatics = Object.setPrototypeOf ||
|
119
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
120
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
121
|
+
return function (d, b) {
|
122
|
+
extendStatics(d, b);
|
123
|
+
function __() { this.constructor = d; }
|
124
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
125
|
+
};
|
126
|
+
})();
|
127
|
+
var pixi_projection;
|
128
|
+
(function (pixi_projection) {
|
129
|
+
function transformHack(parentTransform) {
|
130
|
+
var proj = this.proj;
|
131
|
+
var ta = this;
|
132
|
+
var pwid = parentTransform._worldID;
|
133
|
+
var lt = ta.localTransform;
|
134
|
+
if (ta._localID !== ta._currentLocalID) {
|
135
|
+
lt.a = ta._cx * ta.scale._x;
|
136
|
+
lt.b = ta._sx * ta.scale._x;
|
137
|
+
lt.c = ta._cy * ta.scale._y;
|
138
|
+
lt.d = ta._sy * ta.scale._y;
|
139
|
+
lt.tx = ta.position._x - ((ta.pivot._x * lt.a) + (ta.pivot._y * lt.c));
|
140
|
+
lt.ty = ta.position._y - ((ta.pivot._x * lt.b) + (ta.pivot._y * lt.d));
|
141
|
+
ta._currentLocalID = ta._localID;
|
142
|
+
proj._currentProjID = -1;
|
143
|
+
}
|
144
|
+
var _matrixID = proj._projID;
|
145
|
+
if (proj._currentProjID !== _matrixID) {
|
146
|
+
proj._currentProjID = _matrixID;
|
147
|
+
proj.updateLocalTransform(lt);
|
148
|
+
ta._parentID = -1;
|
149
|
+
}
|
150
|
+
if (ta._parentID !== pwid) {
|
151
|
+
var pp = parentTransform.proj;
|
152
|
+
if (pp && !pp._affine) {
|
153
|
+
proj.world.setToMult(pp.world, proj.local);
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
proj.world.setToMultLegacy(parentTransform.worldTransform, proj.local);
|
157
|
+
}
|
158
|
+
proj.world.copy(ta.worldTransform, proj._affine);
|
159
|
+
ta._parentID = pwid;
|
160
|
+
ta._worldID++;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
var LinearProjection = (function (_super) {
|
164
|
+
__extends(LinearProjection, _super);
|
165
|
+
function LinearProjection() {
|
166
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
167
|
+
_this._projID = 0;
|
168
|
+
_this._currentProjID = -1;
|
169
|
+
_this._affine = pixi_projection.AFFINE.NONE;
|
170
|
+
return _this;
|
171
|
+
}
|
172
|
+
LinearProjection.prototype.updateLocalTransform = function (lt) {
|
173
|
+
};
|
174
|
+
Object.defineProperty(LinearProjection.prototype, "affine", {
|
175
|
+
get: function () {
|
176
|
+
return this._affine;
|
177
|
+
},
|
178
|
+
set: function (value) {
|
179
|
+
if (this._affine == value)
|
180
|
+
return;
|
181
|
+
this._affine = value;
|
182
|
+
this._currentProjID = -1;
|
183
|
+
},
|
184
|
+
enumerable: true,
|
185
|
+
configurable: true
|
186
|
+
});
|
187
|
+
Object.defineProperty(LinearProjection.prototype, "enabled", {
|
188
|
+
set: function (value) {
|
189
|
+
if (value === this._enabled) {
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
this._enabled = value;
|
193
|
+
if (value) {
|
194
|
+
this.legacy.updateTransform = transformHack;
|
195
|
+
this.legacy._parentID = -1;
|
196
|
+
}
|
197
|
+
else {
|
198
|
+
this.legacy.updateTransform = PIXI.TransformStatic.prototype.updateTransform;
|
199
|
+
this.legacy._parentID = -1;
|
200
|
+
}
|
201
|
+
},
|
202
|
+
enumerable: true,
|
203
|
+
configurable: true
|
204
|
+
});
|
205
|
+
LinearProjection.prototype.clear = function () {
|
206
|
+
this._currentProjID = -1;
|
207
|
+
this._projID = 0;
|
208
|
+
};
|
209
|
+
return LinearProjection;
|
210
|
+
}(pixi_projection.AbstractProjection));
|
211
|
+
pixi_projection.LinearProjection = LinearProjection;
|
212
|
+
})(pixi_projection || (pixi_projection = {}));
|
213
|
+
var pixi_projection;
|
214
|
+
(function (pixi_projection) {
|
215
|
+
var webgl;
|
216
|
+
(function (webgl) {
|
217
|
+
var BatchBuffer = (function () {
|
218
|
+
function BatchBuffer(size) {
|
219
|
+
this.vertices = new ArrayBuffer(size);
|
220
|
+
this.float32View = new Float32Array(this.vertices);
|
221
|
+
this.uint32View = new Uint32Array(this.vertices);
|
222
|
+
}
|
223
|
+
BatchBuffer.prototype.destroy = function () {
|
224
|
+
this.vertices = null;
|
225
|
+
};
|
226
|
+
return BatchBuffer;
|
227
|
+
}());
|
228
|
+
webgl.BatchBuffer = BatchBuffer;
|
229
|
+
})(webgl = pixi_projection.webgl || (pixi_projection.webgl = {}));
|
230
|
+
})(pixi_projection || (pixi_projection = {}));
|
231
|
+
var pixi_projection;
|
232
|
+
(function (pixi_projection) {
|
233
|
+
var webgl;
|
234
|
+
(function (webgl) {
|
235
|
+
var ObjectRenderer = PIXI.ObjectRenderer;
|
236
|
+
var settings = PIXI.settings;
|
237
|
+
var GLBuffer = PIXI.glCore.GLBuffer;
|
238
|
+
var premultiplyTint = PIXI.utils.premultiplyTint;
|
239
|
+
var premultiplyBlendMode = PIXI.utils.premultiplyBlendMode;
|
240
|
+
var TICK = 0;
|
241
|
+
var BatchGroup = (function () {
|
242
|
+
function BatchGroup() {
|
243
|
+
this.textures = [];
|
244
|
+
this.textureCount = 0;
|
245
|
+
this.ids = [];
|
246
|
+
this.size = 0;
|
247
|
+
this.start = 0;
|
248
|
+
this.blend = PIXI.BLEND_MODES.NORMAL;
|
249
|
+
this.uniforms = null;
|
250
|
+
}
|
251
|
+
return BatchGroup;
|
252
|
+
}());
|
253
|
+
webgl.BatchGroup = BatchGroup;
|
254
|
+
var MultiTextureSpriteRenderer = (function (_super) {
|
255
|
+
__extends(MultiTextureSpriteRenderer, _super);
|
256
|
+
function MultiTextureSpriteRenderer(renderer) {
|
257
|
+
var _this = _super.call(this, renderer) || this;
|
258
|
+
_this.shaderVert = '';
|
259
|
+
_this.shaderFrag = '';
|
260
|
+
_this.MAX_TEXTURES_LOCAL = 32;
|
261
|
+
_this.vertSize = 5;
|
262
|
+
_this.vertByteSize = _this.vertSize * 4;
|
263
|
+
_this.size = settings.SPRITE_BATCH_SIZE;
|
264
|
+
_this.currentIndex = 0;
|
265
|
+
_this.sprites = [];
|
266
|
+
_this.vertexBuffers = [];
|
267
|
+
_this.vaos = [];
|
268
|
+
_this.vaoMax = 2;
|
269
|
+
_this.vertexCount = 0;
|
270
|
+
_this.MAX_TEXTURES = 1;
|
271
|
+
_this.indices = pixi_projection.utils.createIndicesForQuads(_this.size);
|
272
|
+
_this.groups = [];
|
273
|
+
for (var k = 0; k < _this.size; k++) {
|
274
|
+
_this.groups[k] = new BatchGroup();
|
275
|
+
}
|
276
|
+
_this.vaoMax = 2;
|
277
|
+
_this.vertexCount = 0;
|
278
|
+
_this.renderer.on('prerender', _this.onPrerender, _this);
|
279
|
+
return _this;
|
280
|
+
}
|
281
|
+
MultiTextureSpriteRenderer.prototype.getUniforms = function (spr) {
|
282
|
+
return null;
|
283
|
+
};
|
284
|
+
MultiTextureSpriteRenderer.prototype.syncUniforms = function (obj) {
|
285
|
+
if (!obj)
|
286
|
+
return;
|
287
|
+
var sh = this.shader;
|
288
|
+
for (var key in obj) {
|
289
|
+
sh.uniforms[key] = obj[key];
|
290
|
+
}
|
291
|
+
};
|
292
|
+
MultiTextureSpriteRenderer.prototype.onContextChange = function () {
|
293
|
+
var gl = this.renderer.gl;
|
294
|
+
this.MAX_TEXTURES = Math.min(this.MAX_TEXTURES_LOCAL, this.renderer.plugins['sprite'].MAX_TEXTURES);
|
295
|
+
this.shader = webgl.generateMultiTextureShader(this.shaderVert, this.shaderFrag, gl, this.MAX_TEXTURES);
|
296
|
+
this.indexBuffer = GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);
|
297
|
+
this.renderer.bindVao(null);
|
298
|
+
var attrs = this.shader.attributes;
|
299
|
+
for (var i = 0; i < this.vaoMax; i++) {
|
300
|
+
var vertexBuffer = this.vertexBuffers[i] = GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);
|
301
|
+
this.vaos[i] = this.createVao(vertexBuffer);
|
302
|
+
}
|
303
|
+
if (!this.buffers) {
|
304
|
+
this.buffers = [];
|
305
|
+
for (var i = 1; i <= pixi_projection.utils.nextPow2(this.size); i *= 2) {
|
306
|
+
this.buffers.push(new webgl.BatchBuffer(i * 4 * this.vertByteSize));
|
307
|
+
}
|
308
|
+
}
|
309
|
+
this.vao = this.vaos[0];
|
310
|
+
};
|
311
|
+
MultiTextureSpriteRenderer.prototype.onPrerender = function () {
|
312
|
+
this.vertexCount = 0;
|
313
|
+
};
|
314
|
+
MultiTextureSpriteRenderer.prototype.render = function (sprite) {
|
315
|
+
if (this.currentIndex >= this.size) {
|
316
|
+
this.flush();
|
317
|
+
}
|
318
|
+
if (!sprite._texture._uvs) {
|
319
|
+
return;
|
320
|
+
}
|
321
|
+
if (!sprite._texture.baseTexture) {
|
322
|
+
return;
|
323
|
+
}
|
324
|
+
this.sprites[this.currentIndex++] = sprite;
|
325
|
+
};
|
326
|
+
MultiTextureSpriteRenderer.prototype.flush = function () {
|
327
|
+
if (this.currentIndex === 0) {
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
var gl = this.renderer.gl;
|
331
|
+
var MAX_TEXTURES = this.MAX_TEXTURES;
|
332
|
+
var np2 = pixi_projection.utils.nextPow2(this.currentIndex);
|
333
|
+
var log2 = pixi_projection.utils.log2(np2);
|
334
|
+
var buffer = this.buffers[log2];
|
335
|
+
var sprites = this.sprites;
|
336
|
+
var groups = this.groups;
|
337
|
+
var float32View = buffer.float32View;
|
338
|
+
var uint32View = buffer.uint32View;
|
339
|
+
var index = 0;
|
340
|
+
var nextTexture;
|
341
|
+
var currentTexture;
|
342
|
+
var currentUniforms = null;
|
343
|
+
var groupCount = 1;
|
344
|
+
var textureCount = 0;
|
345
|
+
var currentGroup = groups[0];
|
346
|
+
var vertexData;
|
347
|
+
var uvs;
|
348
|
+
var blendMode = premultiplyBlendMode[sprites[0]._texture.baseTexture.premultipliedAlpha ? 1 : 0][sprites[0].blendMode];
|
349
|
+
currentGroup.textureCount = 0;
|
350
|
+
currentGroup.start = 0;
|
351
|
+
currentGroup.blend = blendMode;
|
352
|
+
TICK++;
|
353
|
+
var i;
|
354
|
+
for (i = 0; i < this.currentIndex; ++i) {
|
355
|
+
var sprite = sprites[i];
|
356
|
+
nextTexture = sprite._texture.baseTexture;
|
357
|
+
var spriteBlendMode = premultiplyBlendMode[Number(nextTexture.premultipliedAlpha)][sprite.blendMode];
|
358
|
+
if (blendMode !== spriteBlendMode) {
|
359
|
+
blendMode = spriteBlendMode;
|
360
|
+
currentTexture = null;
|
361
|
+
textureCount = MAX_TEXTURES;
|
362
|
+
TICK++;
|
363
|
+
}
|
364
|
+
var uniforms = this.getUniforms(sprite);
|
365
|
+
if (currentUniforms !== uniforms) {
|
366
|
+
currentUniforms = uniforms;
|
367
|
+
currentTexture = null;
|
368
|
+
textureCount = MAX_TEXTURES;
|
369
|
+
TICK++;
|
370
|
+
}
|
371
|
+
if (currentTexture !== nextTexture) {
|
372
|
+
currentTexture = nextTexture;
|
373
|
+
if (nextTexture._enabled !== TICK) {
|
374
|
+
if (textureCount === MAX_TEXTURES) {
|
375
|
+
TICK++;
|
376
|
+
textureCount = 0;
|
377
|
+
currentGroup.size = i - currentGroup.start;
|
378
|
+
currentGroup = groups[groupCount++];
|
379
|
+
currentGroup.textureCount = 0;
|
380
|
+
currentGroup.blend = blendMode;
|
381
|
+
currentGroup.start = i;
|
382
|
+
currentGroup.uniforms = currentUniforms;
|
383
|
+
}
|
384
|
+
nextTexture._enabled = TICK;
|
385
|
+
nextTexture._virtalBoundId = textureCount;
|
386
|
+
currentGroup.textures[currentGroup.textureCount++] = nextTexture;
|
387
|
+
textureCount++;
|
388
|
+
}
|
389
|
+
}
|
390
|
+
var alpha = Math.min(sprite.worldAlpha, 1.0);
|
391
|
+
var argb = alpha < 1.0 && nextTexture.premultipliedAlpha ? premultiplyTint(sprite._tintRGB, alpha)
|
392
|
+
: sprite._tintRGB + (alpha * 255 << 24);
|
393
|
+
this.fillVertices(float32View, uint32View, index, sprite, argb, nextTexture._virtalBoundId);
|
394
|
+
index += this.vertSize * 4;
|
395
|
+
}
|
396
|
+
currentGroup.size = i - currentGroup.start;
|
397
|
+
if (!settings.CAN_UPLOAD_SAME_BUFFER) {
|
398
|
+
if (this.vaoMax <= this.vertexCount) {
|
399
|
+
this.vaoMax++;
|
400
|
+
var attrs = this.shader.attributes;
|
401
|
+
var vertexBuffer = this.vertexBuffers[this.vertexCount] = GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);
|
402
|
+
this.vaos[this.vertexCount] = this.createVao(vertexBuffer);
|
403
|
+
}
|
404
|
+
this.renderer.bindVao(this.vaos[this.vertexCount]);
|
405
|
+
this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, false);
|
406
|
+
this.vertexCount++;
|
407
|
+
}
|
408
|
+
else {
|
409
|
+
this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, true);
|
410
|
+
}
|
411
|
+
currentUniforms = null;
|
412
|
+
for (i = 0; i < groupCount; i++) {
|
413
|
+
var group = groups[i];
|
414
|
+
var groupTextureCount = group.textureCount;
|
415
|
+
if (group.uniforms !== currentUniforms) {
|
416
|
+
this.syncUniforms(group.uniforms);
|
417
|
+
}
|
418
|
+
for (var j = 0; j < groupTextureCount; j++) {
|
419
|
+
this.renderer.bindTexture(group.textures[j], j, true);
|
420
|
+
group.textures[j]._virtalBoundId = -1;
|
421
|
+
var v = this.shader.uniforms.samplerSize;
|
422
|
+
if (v) {
|
423
|
+
v[0] = group.textures[j].realWidth;
|
424
|
+
v[1] = group.textures[j].realHeight;
|
425
|
+
this.shader.uniforms.samplerSize = v;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
this.renderer.state.setBlendMode(group.blend);
|
429
|
+
gl.drawElements(gl.TRIANGLES, group.size * 6, gl.UNSIGNED_SHORT, group.start * 6 * 2);
|
430
|
+
}
|
431
|
+
this.currentIndex = 0;
|
432
|
+
};
|
433
|
+
MultiTextureSpriteRenderer.prototype.start = function () {
|
434
|
+
this.renderer.bindShader(this.shader);
|
435
|
+
if (settings.CAN_UPLOAD_SAME_BUFFER) {
|
436
|
+
this.renderer.bindVao(this.vaos[this.vertexCount]);
|
437
|
+
this.vertexBuffers[this.vertexCount].bind();
|
438
|
+
}
|
439
|
+
};
|
440
|
+
MultiTextureSpriteRenderer.prototype.stop = function () {
|
441
|
+
this.flush();
|
442
|
+
};
|
443
|
+
MultiTextureSpriteRenderer.prototype.destroy = function () {
|
444
|
+
for (var i = 0; i < this.vaoMax; i++) {
|
445
|
+
if (this.vertexBuffers[i]) {
|
446
|
+
this.vertexBuffers[i].destroy();
|
447
|
+
}
|
448
|
+
if (this.vaos[i]) {
|
449
|
+
this.vaos[i].destroy();
|
450
|
+
}
|
451
|
+
}
|
452
|
+
if (this.indexBuffer) {
|
453
|
+
this.indexBuffer.destroy();
|
454
|
+
}
|
455
|
+
this.renderer.off('prerender', this.onPrerender, this);
|
456
|
+
_super.prototype.destroy.call(this);
|
457
|
+
if (this.shader) {
|
458
|
+
this.shader.destroy();
|
459
|
+
this.shader = null;
|
460
|
+
}
|
461
|
+
this.vertexBuffers = null;
|
462
|
+
this.vaos = null;
|
463
|
+
this.indexBuffer = null;
|
464
|
+
this.indices = null;
|
465
|
+
this.sprites = null;
|
466
|
+
for (var i = 0; i < this.buffers.length; ++i) {
|
467
|
+
this.buffers[i].destroy();
|
468
|
+
}
|
469
|
+
};
|
470
|
+
return MultiTextureSpriteRenderer;
|
471
|
+
}(ObjectRenderer));
|
472
|
+
webgl.MultiTextureSpriteRenderer = MultiTextureSpriteRenderer;
|
473
|
+
})(webgl = pixi_projection.webgl || (pixi_projection.webgl = {}));
|
474
|
+
})(pixi_projection || (pixi_projection = {}));
|
475
|
+
var pixi_projection;
|
476
|
+
(function (pixi_projection) {
|
477
|
+
var webgl;
|
478
|
+
(function (webgl) {
|
479
|
+
function generateMultiTextureShader(vertexSrc, fragmentSrc, gl, maxTextures) {
|
480
|
+
fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures + '');
|
481
|
+
fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures));
|
482
|
+
var shader = new PIXI.Shader(gl, vertexSrc, fragmentSrc);
|
483
|
+
var sampleValues = new Int32Array(maxTextures);
|
484
|
+
for (var i = 0; i < maxTextures; i++) {
|
485
|
+
sampleValues[i] = i;
|
486
|
+
}
|
487
|
+
shader.bind();
|
488
|
+
shader.uniforms.uSamplers = sampleValues;
|
489
|
+
return shader;
|
490
|
+
}
|
491
|
+
webgl.generateMultiTextureShader = generateMultiTextureShader;
|
492
|
+
function generateSampleSrc(maxTextures) {
|
493
|
+
var src = '';
|
494
|
+
src += '\n';
|
495
|
+
src += '\n';
|
496
|
+
for (var i = 0; i < maxTextures; i++) {
|
497
|
+
if (i > 0) {
|
498
|
+
src += '\nelse ';
|
499
|
+
}
|
500
|
+
if (i < maxTextures - 1) {
|
501
|
+
src += "if(textureId == " + i + ".0)";
|
502
|
+
}
|
503
|
+
src += '\n{';
|
504
|
+
src += "\n\tcolor = texture2D(uSamplers[" + i + "], textureCoord);";
|
505
|
+
src += '\n}';
|
506
|
+
}
|
507
|
+
src += '\n';
|
508
|
+
src += '\n';
|
509
|
+
return src;
|
510
|
+
}
|
511
|
+
})(webgl = pixi_projection.webgl || (pixi_projection.webgl = {}));
|
512
|
+
})(pixi_projection || (pixi_projection = {}));
|
513
|
+
var pixi_projection;
|
514
|
+
(function (pixi_projection) {
|
515
|
+
var p = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()];
|
516
|
+
var a = [0, 0, 0, 0];
|
517
|
+
var Surface = (function () {
|
518
|
+
function Surface() {
|
519
|
+
this.surfaceID = "default";
|
520
|
+
this._updateID = 0;
|
521
|
+
this.vertexSrc = "";
|
522
|
+
this.fragmentSrc = "";
|
523
|
+
}
|
524
|
+
Surface.prototype.fillUniforms = function (uniforms) {
|
525
|
+
};
|
526
|
+
Surface.prototype.clear = function () {
|
527
|
+
};
|
528
|
+
Surface.prototype.boundsQuad = function (v, out, after) {
|
529
|
+
var minX = out[0], minY = out[1];
|
530
|
+
var maxX = out[0], maxY = out[1];
|
531
|
+
for (var i = 2; i < 8; i += 2) {
|
532
|
+
if (minX > out[i])
|
533
|
+
minX = out[i];
|
534
|
+
if (maxX < out[i])
|
535
|
+
maxX = out[i];
|
536
|
+
if (minY > out[i + 1])
|
537
|
+
minY = out[i + 1];
|
538
|
+
if (maxY < out[i + 1])
|
539
|
+
maxY = out[i + 1];
|
540
|
+
}
|
541
|
+
p[0].set(minX, minY);
|
542
|
+
this.apply(p[0], p[0]);
|
543
|
+
p[1].set(maxX, minY);
|
544
|
+
this.apply(p[1], p[1]);
|
545
|
+
p[2].set(maxX, maxY);
|
546
|
+
this.apply(p[2], p[2]);
|
547
|
+
p[3].set(minX, maxY);
|
548
|
+
this.apply(p[3], p[3]);
|
549
|
+
if (after) {
|
550
|
+
after.apply(p[0], p[0]);
|
551
|
+
after.apply(p[1], p[1]);
|
552
|
+
after.apply(p[2], p[2]);
|
553
|
+
after.apply(p[3], p[3]);
|
554
|
+
out[0] = p[0].x;
|
555
|
+
out[1] = p[0].y;
|
556
|
+
out[2] = p[1].x;
|
557
|
+
out[3] = p[1].y;
|
558
|
+
out[4] = p[2].x;
|
559
|
+
out[5] = p[2].y;
|
560
|
+
out[6] = p[3].x;
|
561
|
+
out[7] = p[3].y;
|
562
|
+
}
|
563
|
+
else {
|
564
|
+
for (var i = 1; i <= 3; i++) {
|
565
|
+
if (p[i].y < p[0].y || p[i].y == p[0].y && p[i].x < p[0].x) {
|
566
|
+
var t = p[0];
|
567
|
+
p[0] = p[i];
|
568
|
+
p[i] = t;
|
569
|
+
}
|
570
|
+
}
|
571
|
+
for (var i = 1; i <= 3; i++) {
|
572
|
+
a[i] = Math.atan2(p[i].y - p[0].y, p[i].x - p[0].x);
|
573
|
+
}
|
574
|
+
for (var i = 1; i <= 3; i++) {
|
575
|
+
for (var j = i + 1; j <= 3; j++) {
|
576
|
+
if (a[i] > a[j]) {
|
577
|
+
var t = p[i];
|
578
|
+
p[i] = p[j];
|
579
|
+
p[j] = t;
|
580
|
+
var t2 = a[i];
|
581
|
+
a[i] = a[j];
|
582
|
+
a[j] = t2;
|
583
|
+
}
|
584
|
+
}
|
585
|
+
}
|
586
|
+
out[0] = p[0].x;
|
587
|
+
out[1] = p[0].y;
|
588
|
+
out[2] = p[1].x;
|
589
|
+
out[3] = p[1].y;
|
590
|
+
out[4] = p[2].x;
|
591
|
+
out[5] = p[2].y;
|
592
|
+
out[6] = p[3].x;
|
593
|
+
out[7] = p[3].y;
|
594
|
+
if ((p[3].x - p[2].x) * (p[1].y - p[2].y) - (p[1].x - p[2].x) * (p[3].y - p[2].y) < 0) {
|
595
|
+
out[4] = p[3].x;
|
596
|
+
out[5] = p[3].y;
|
597
|
+
return;
|
598
|
+
}
|
599
|
+
}
|
600
|
+
};
|
601
|
+
return Surface;
|
602
|
+
}());
|
603
|
+
pixi_projection.Surface = Surface;
|
604
|
+
})(pixi_projection || (pixi_projection = {}));
|
605
|
+
var pixi_projection;
|
606
|
+
(function (pixi_projection) {
|
607
|
+
var tempMat = new PIXI.Matrix();
|
608
|
+
var tempRect = new PIXI.Rectangle();
|
609
|
+
var tempPoint = new PIXI.Point();
|
610
|
+
var BilinearSurface = (function (_super) {
|
611
|
+
__extends(BilinearSurface, _super);
|
612
|
+
function BilinearSurface() {
|
613
|
+
var _this = _super.call(this) || this;
|
614
|
+
_this.distortion = new PIXI.Point();
|
615
|
+
return _this;
|
616
|
+
}
|
617
|
+
BilinearSurface.prototype.clear = function () {
|
618
|
+
this.distortion.set(0, 0);
|
619
|
+
};
|
620
|
+
BilinearSurface.prototype.apply = function (pos, newPos) {
|
621
|
+
newPos = newPos || new PIXI.Point();
|
622
|
+
var d = this.distortion;
|
623
|
+
var m = pos.x * pos.y;
|
624
|
+
newPos.x = pos.x + d.x * m;
|
625
|
+
newPos.y = pos.y + d.y * m;
|
626
|
+
return newPos;
|
627
|
+
};
|
628
|
+
BilinearSurface.prototype.applyInverse = function (pos, newPos) {
|
629
|
+
newPos = newPos || new PIXI.Point();
|
630
|
+
var vx = pos.x, vy = pos.y;
|
631
|
+
var dx = this.distortion.x, dy = this.distortion.y;
|
632
|
+
if (dx == 0.0) {
|
633
|
+
newPos.x = vx;
|
634
|
+
newPos.y = vy / (1.0 + dy * vx);
|
635
|
+
}
|
636
|
+
else if (dy == 0.0) {
|
637
|
+
newPos.y = vy;
|
638
|
+
newPos.x = vx / (1.0 + dx * vy);
|
639
|
+
}
|
640
|
+
else {
|
641
|
+
var b = (vy * dx - vx * dy + 1.0) * 0.5 / dy;
|
642
|
+
var d = b * b + vx / dy;
|
643
|
+
if (d <= 0.00001) {
|
644
|
+
newPos.set(NaN, NaN);
|
645
|
+
return;
|
646
|
+
}
|
647
|
+
if (dy > 0.0) {
|
648
|
+
newPos.x = -b + Math.sqrt(d);
|
649
|
+
}
|
650
|
+
else {
|
651
|
+
newPos.x = -b - Math.sqrt(d);
|
652
|
+
}
|
653
|
+
newPos.y = (vx / newPos.x - 1.0) / dx;
|
654
|
+
}
|
655
|
+
return newPos;
|
656
|
+
};
|
657
|
+
BilinearSurface.prototype.mapSprite = function (sprite, quad, outTransform) {
|
658
|
+
var tex = sprite.texture;
|
659
|
+
tempRect.x = -sprite.anchor.x * tex.orig.width;
|
660
|
+
tempRect.y = -sprite.anchor.y * tex.orig.height;
|
661
|
+
tempRect.width = tex.orig.width;
|
662
|
+
tempRect.height = tex.orig.height;
|
663
|
+
return this.mapQuad(tempRect, quad, outTransform || sprite.transform);
|
664
|
+
};
|
665
|
+
BilinearSurface.prototype.mapQuad = function (rect, quad, outTransform) {
|
666
|
+
var ax = -rect.x / rect.width;
|
667
|
+
var ay = -rect.y / rect.height;
|
668
|
+
var ax2 = (1.0 - rect.x) / rect.width;
|
669
|
+
var ay2 = (1.0 - rect.y) / rect.height;
|
670
|
+
var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax);
|
671
|
+
var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax);
|
672
|
+
var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2);
|
673
|
+
var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2);
|
674
|
+
var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax);
|
675
|
+
var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax);
|
676
|
+
var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2);
|
677
|
+
var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2);
|
678
|
+
var x00 = up1x * (1.0 - ay) + down1x * ay;
|
679
|
+
var y00 = up1y * (1.0 - ay) + down1y * ay;
|
680
|
+
var x10 = up2x * (1.0 - ay) + down2x * ay;
|
681
|
+
var y10 = up2y * (1.0 - ay) + down2y * ay;
|
682
|
+
var x01 = up1x * (1.0 - ay2) + down1x * ay2;
|
683
|
+
var y01 = up1y * (1.0 - ay2) + down1y * ay2;
|
684
|
+
var x11 = up2x * (1.0 - ay2) + down2x * ay2;
|
685
|
+
var y11 = up2y * (1.0 - ay2) + down2y * ay2;
|
686
|
+
var mat = tempMat;
|
687
|
+
mat.tx = x00;
|
688
|
+
mat.ty = y00;
|
689
|
+
mat.a = x10 - x00;
|
690
|
+
mat.b = y10 - y00;
|
691
|
+
mat.c = x01 - x00;
|
692
|
+
mat.d = y01 - y00;
|
693
|
+
tempPoint.set(x11, y11);
|
694
|
+
mat.applyInverse(tempPoint, tempPoint);
|
695
|
+
this.distortion.set(tempPoint.x - 1, tempPoint.y - 1);
|
696
|
+
outTransform.setFromMatrix(mat);
|
697
|
+
return this;
|
698
|
+
};
|
699
|
+
BilinearSurface.prototype.fillUniforms = function (uniforms) {
|
700
|
+
uniforms.distortion = uniforms.distortion || new Float32Array([0, 0, 0, 0]);
|
701
|
+
var ax = Math.abs(this.distortion.x);
|
702
|
+
var ay = Math.abs(this.distortion.y);
|
703
|
+
uniforms.distortion[0] = ax * 10000 <= ay ? 0 : this.distortion.x;
|
704
|
+
uniforms.distortion[1] = ay * 10000 <= ax ? 0 : this.distortion.y;
|
705
|
+
uniforms.distortion[2] = 1.0 / uniforms.distortion[0];
|
706
|
+
uniforms.distortion[3] = 1.0 / uniforms.distortion[1];
|
707
|
+
};
|
708
|
+
return BilinearSurface;
|
709
|
+
}(pixi_projection.Surface));
|
710
|
+
pixi_projection.BilinearSurface = BilinearSurface;
|
711
|
+
})(pixi_projection || (pixi_projection = {}));
|
712
|
+
var pixi_projection;
|
713
|
+
(function (pixi_projection) {
|
714
|
+
var Container2s = (function (_super) {
|
715
|
+
__extends(Container2s, _super);
|
716
|
+
function Container2s() {
|
717
|
+
var _this = _super.call(this) || this;
|
718
|
+
_this.proj = new pixi_projection.ProjectionSurface(_this.transform);
|
719
|
+
return _this;
|
720
|
+
}
|
721
|
+
Object.defineProperty(Container2s.prototype, "worldTransform", {
|
722
|
+
get: function () {
|
723
|
+
return this.proj;
|
724
|
+
},
|
725
|
+
enumerable: true,
|
726
|
+
configurable: true
|
727
|
+
});
|
728
|
+
return Container2s;
|
729
|
+
}(PIXI.Container));
|
730
|
+
pixi_projection.Container2s = Container2s;
|
731
|
+
})(pixi_projection || (pixi_projection = {}));
|
732
|
+
var pixi_projection;
|
733
|
+
(function (pixi_projection) {
|
734
|
+
var fun = PIXI.TransformStatic.prototype.updateTransform;
|
735
|
+
function transformHack(parentTransform) {
|
736
|
+
var proj = this.proj;
|
737
|
+
var pp = parentTransform.proj;
|
738
|
+
var ta = this;
|
739
|
+
if (!pp) {
|
740
|
+
fun.call(this, parentTransform);
|
741
|
+
proj._activeProjection = null;
|
742
|
+
return;
|
743
|
+
}
|
744
|
+
if (pp._surface) {
|
745
|
+
proj._activeProjection = pp;
|
746
|
+
this.updateLocalTransform();
|
747
|
+
this.localTransform.copy(this.worldTransform);
|
748
|
+
if (ta._parentID < 0) {
|
749
|
+
++ta._worldID;
|
750
|
+
}
|
751
|
+
return;
|
752
|
+
}
|
753
|
+
fun.call(this, parentTransform);
|
754
|
+
proj._activeProjection = pp._activeProjection;
|
755
|
+
}
|
756
|
+
var ProjectionSurface = (function (_super) {
|
757
|
+
__extends(ProjectionSurface, _super);
|
758
|
+
function ProjectionSurface(legacy, enable) {
|
759
|
+
var _this = _super.call(this, legacy, enable) || this;
|
760
|
+
_this._surface = null;
|
761
|
+
_this._activeProjection = null;
|
762
|
+
_this._currentSurfaceID = -1;
|
763
|
+
_this._currentLegacyID = -1;
|
764
|
+
_this._lastUniforms = null;
|
765
|
+
return _this;
|
766
|
+
}
|
767
|
+
Object.defineProperty(ProjectionSurface.prototype, "enabled", {
|
768
|
+
set: function (value) {
|
769
|
+
if (value === this._enabled) {
|
770
|
+
return;
|
771
|
+
}
|
772
|
+
this._enabled = value;
|
773
|
+
if (value) {
|
774
|
+
this.legacy.updateTransform = transformHack;
|
775
|
+
this.legacy._parentID = -1;
|
776
|
+
}
|
777
|
+
else {
|
778
|
+
this.legacy.updateTransform = PIXI.TransformStatic.prototype.updateTransform;
|
779
|
+
this.legacy._parentID = -1;
|
780
|
+
}
|
781
|
+
},
|
782
|
+
enumerable: true,
|
783
|
+
configurable: true
|
784
|
+
});
|
785
|
+
Object.defineProperty(ProjectionSurface.prototype, "surface", {
|
786
|
+
get: function () {
|
787
|
+
return this._surface;
|
788
|
+
},
|
789
|
+
set: function (value) {
|
790
|
+
if (this._surface == value) {
|
791
|
+
return;
|
792
|
+
}
|
793
|
+
this._surface = value || null;
|
794
|
+
this.legacy._parentID = -1;
|
795
|
+
},
|
796
|
+
enumerable: true,
|
797
|
+
configurable: true
|
798
|
+
});
|
799
|
+
ProjectionSurface.prototype.applyPartial = function (pos, newPos) {
|
800
|
+
if (this._activeProjection !== null) {
|
801
|
+
newPos = this.legacy.worldTransform.apply(pos, newPos);
|
802
|
+
return this._activeProjection.surface.apply(newPos, newPos);
|
803
|
+
}
|
804
|
+
if (this._surface !== null) {
|
805
|
+
return this.surface.apply(pos, newPos);
|
806
|
+
}
|
807
|
+
return this.legacy.worldTransform.apply(pos, newPos);
|
808
|
+
};
|
809
|
+
ProjectionSurface.prototype.apply = function (pos, newPos) {
|
810
|
+
if (this._activeProjection !== null) {
|
811
|
+
newPos = this.legacy.worldTransform.apply(pos, newPos);
|
812
|
+
this._activeProjection.surface.apply(newPos, newPos);
|
813
|
+
return this._activeProjection.legacy.worldTransform.apply(newPos, newPos);
|
814
|
+
}
|
815
|
+
if (this._surface !== null) {
|
816
|
+
newPos = this.surface.apply(pos, newPos);
|
817
|
+
return this.legacy.worldTransform.apply(newPos, newPos);
|
818
|
+
}
|
819
|
+
return this.legacy.worldTransform.apply(pos, newPos);
|
820
|
+
};
|
821
|
+
ProjectionSurface.prototype.applyInverse = function (pos, newPos) {
|
822
|
+
if (this._activeProjection !== null) {
|
823
|
+
newPos = this._activeProjection.legacy.worldTransform.applyInverse(pos, newPos);
|
824
|
+
this._activeProjection._surface.applyInverse(newPos, newPos);
|
825
|
+
return this.legacy.worldTransform.applyInverse(newPos, newPos);
|
826
|
+
}
|
827
|
+
if (this._surface !== null) {
|
828
|
+
newPos = this.legacy.worldTransform.applyInverse(pos, newPos);
|
829
|
+
return this._surface.applyInverse(newPos, newPos);
|
830
|
+
}
|
831
|
+
return this.legacy.worldTransform.applyInverse(pos, newPos);
|
832
|
+
};
|
833
|
+
ProjectionSurface.prototype.mapBilinearSprite = function (sprite, quad) {
|
834
|
+
if (!(this._surface instanceof pixi_projection.BilinearSurface)) {
|
835
|
+
this.surface = new pixi_projection.BilinearSurface();
|
836
|
+
}
|
837
|
+
this.surface.mapSprite(sprite, quad, this.legacy);
|
838
|
+
};
|
839
|
+
ProjectionSurface.prototype.clear = function () {
|
840
|
+
if (this.surface) {
|
841
|
+
this.surface.clear();
|
842
|
+
}
|
843
|
+
};
|
844
|
+
Object.defineProperty(ProjectionSurface.prototype, "uniforms", {
|
845
|
+
get: function () {
|
846
|
+
if (this._currentLegacyID === this.legacy._worldID &&
|
847
|
+
this._currentSurfaceID === this.surface._updateID) {
|
848
|
+
return this._lastUniforms;
|
849
|
+
}
|
850
|
+
this._lastUniforms = this._lastUniforms || {};
|
851
|
+
this._lastUniforms.worldTransform = this.legacy.worldTransform.toArray(true);
|
852
|
+
this._surface.fillUniforms(this._lastUniforms);
|
853
|
+
return this._lastUniforms;
|
854
|
+
},
|
855
|
+
enumerable: true,
|
856
|
+
configurable: true
|
857
|
+
});
|
858
|
+
return ProjectionSurface;
|
859
|
+
}(pixi_projection.AbstractProjection));
|
860
|
+
pixi_projection.ProjectionSurface = ProjectionSurface;
|
861
|
+
})(pixi_projection || (pixi_projection = {}));
|
862
|
+
var pixi_projection;
|
863
|
+
(function (pixi_projection) {
|
864
|
+
var MultiTextureSpriteRenderer = pixi_projection.webgl.MultiTextureSpriteRenderer;
|
865
|
+
var SpriteBilinearRenderer = (function (_super) {
|
866
|
+
__extends(SpriteBilinearRenderer, _super);
|
867
|
+
function SpriteBilinearRenderer() {
|
868
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
869
|
+
_this.size = 100;
|
870
|
+
_this.MAX_TEXTURES_LOCAL = 1;
|
871
|
+
_this.shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n";
|
872
|
+
_this.shaderFrag = "precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 distortion;\n\nvoid main(void){\nvec2 surface;\nvec2 surface2;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat dx = distortion.x;\nfloat dy = distortion.y;\nfloat revx = distortion.z;\nfloat revy = distortion.w;\n\nif (distortion.x == 0.0) {\n surface.x = vx;\n surface.y = vy / (1.0 + dy * vx);\n surface2 = surface;\n} else\nif (distortion.y == 0.0) {\n surface.y = vy;\n surface.x = vx/ (1.0 + dx * vy);\n surface2 = surface;\n} else {\n float c = vy * dx - vx * dy;\n float b = (c + 1.0) * 0.5;\n float b2 = (-c + 1.0) * 0.5;\n float d = b * b + vx * dy;\n if (d < -0.00001) {\n discard;\n }\n d = sqrt(max(d, 0.0));\n surface.x = (- b + d) * revy;\n surface2.x = (- b - d) * revy;\n surface.y = (- b2 + d) * revx;\n surface2.y = (- b2 - d) * revx;\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nif (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}";
|
873
|
+
_this.defUniforms = {
|
874
|
+
worldTransform: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]),
|
875
|
+
distortion: new Float32Array([0, 0])
|
876
|
+
};
|
877
|
+
return _this;
|
878
|
+
}
|
879
|
+
SpriteBilinearRenderer.prototype.getUniforms = function (sprite) {
|
880
|
+
var proj = sprite.proj;
|
881
|
+
var shader = this.shader;
|
882
|
+
if (proj.surface !== null) {
|
883
|
+
return proj.uniforms;
|
884
|
+
}
|
885
|
+
if (proj._activeProjection !== null) {
|
886
|
+
return proj._activeProjection.uniforms;
|
887
|
+
}
|
888
|
+
return this.defUniforms;
|
889
|
+
};
|
890
|
+
SpriteBilinearRenderer.prototype.createVao = function (vertexBuffer) {
|
891
|
+
var attrs = this.shader.attributes;
|
892
|
+
this.vertSize = 14;
|
893
|
+
this.vertByteSize = this.vertSize * 4;
|
894
|
+
var gl = this.renderer.gl;
|
895
|
+
var vao = this.renderer.createVao()
|
896
|
+
.addIndex(this.indexBuffer)
|
897
|
+
.addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0)
|
898
|
+
.addAttribute(vertexBuffer, attrs.aTrans1, gl.FLOAT, false, this.vertByteSize, 2 * 4)
|
899
|
+
.addAttribute(vertexBuffer, attrs.aTrans2, gl.FLOAT, false, this.vertByteSize, 5 * 4)
|
900
|
+
.addAttribute(vertexBuffer, attrs.aFrame, gl.FLOAT, false, this.vertByteSize, 8 * 4)
|
901
|
+
.addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 12 * 4);
|
902
|
+
if (attrs.aTextureId) {
|
903
|
+
vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 13 * 4);
|
904
|
+
}
|
905
|
+
return vao;
|
906
|
+
};
|
907
|
+
SpriteBilinearRenderer.prototype.fillVertices = function (float32View, uint32View, index, sprite, argb, textureId) {
|
908
|
+
var vertexData = sprite.vertexData;
|
909
|
+
var tex = sprite._texture;
|
910
|
+
var w = tex.orig.width;
|
911
|
+
var h = tex.orig.height;
|
912
|
+
var ax = sprite._anchor._x;
|
913
|
+
var ay = sprite._anchor._y;
|
914
|
+
var frame = tex._frame;
|
915
|
+
var aTrans = sprite.aTrans;
|
916
|
+
for (var i = 0; i < 4; i++) {
|
917
|
+
float32View[index] = vertexData[i * 2];
|
918
|
+
float32View[index + 1] = vertexData[i * 2 + 1];
|
919
|
+
float32View[index + 2] = aTrans.a;
|
920
|
+
float32View[index + 3] = aTrans.c;
|
921
|
+
float32View[index + 4] = aTrans.tx;
|
922
|
+
float32View[index + 5] = aTrans.b;
|
923
|
+
float32View[index + 6] = aTrans.d;
|
924
|
+
float32View[index + 7] = aTrans.ty;
|
925
|
+
float32View[index + 8] = frame.x;
|
926
|
+
float32View[index + 9] = frame.y;
|
927
|
+
float32View[index + 10] = frame.x + frame.width;
|
928
|
+
float32View[index + 11] = frame.y + frame.height;
|
929
|
+
uint32View[index + 12] = argb;
|
930
|
+
float32View[index + 13] = textureId;
|
931
|
+
index += 14;
|
932
|
+
}
|
933
|
+
};
|
934
|
+
return SpriteBilinearRenderer;
|
935
|
+
}(MultiTextureSpriteRenderer));
|
936
|
+
PIXI.WebGLRenderer.registerPlugin('sprite_bilinear', SpriteBilinearRenderer);
|
937
|
+
})(pixi_projection || (pixi_projection = {}));
|
938
|
+
var pixi_projection;
|
939
|
+
(function (pixi_projection) {
|
940
|
+
var MultiTextureSpriteRenderer = pixi_projection.webgl.MultiTextureSpriteRenderer;
|
941
|
+
var SpriteStrangeRenderer = (function (_super) {
|
942
|
+
__extends(SpriteStrangeRenderer, _super);
|
943
|
+
function SpriteStrangeRenderer() {
|
944
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
945
|
+
_this.size = 100;
|
946
|
+
_this.MAX_TEXTURES_LOCAL = 1;
|
947
|
+
_this.shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n";
|
948
|
+
_this.shaderFrag = "precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 params;\n\nvoid main(void){\nvec2 surface;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat aleph = params.x;\nfloat bet = params.y;\nfloat A = params.z;\nfloat B = params.w;\n\nif (aleph == 0.0) {\n\tsurface.y = vy / (1.0 + vx * bet);\n\tsurface.x = vx;\n}\nelse if (bet == 0.0) {\n\tsurface.x = vx / (1.0 + vy * aleph);\n\tsurface.y = vy;\n} else {\n\tsurface.x = vx * (bet + 1.0) / (bet + 1.0 + vy * aleph);\n\tsurface.y = vy * (aleph + 1.0) / (aleph + 1.0 + vx * bet);\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}";
|
949
|
+
_this.defUniforms = {
|
950
|
+
worldTransform: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]),
|
951
|
+
distortion: new Float32Array([0, 0])
|
952
|
+
};
|
953
|
+
return _this;
|
954
|
+
}
|
955
|
+
SpriteStrangeRenderer.prototype.getUniforms = function (sprite) {
|
956
|
+
var proj = sprite.proj;
|
957
|
+
var shader = this.shader;
|
958
|
+
if (proj.surface !== null) {
|
959
|
+
return proj.uniforms;
|
960
|
+
}
|
961
|
+
if (proj._activeProjection !== null) {
|
962
|
+
return proj._activeProjection.uniforms;
|
963
|
+
}
|
964
|
+
return this.defUniforms;
|
965
|
+
};
|
966
|
+
SpriteStrangeRenderer.prototype.createVao = function (vertexBuffer) {
|
967
|
+
var attrs = this.shader.attributes;
|
968
|
+
this.vertSize = 14;
|
969
|
+
this.vertByteSize = this.vertSize * 4;
|
970
|
+
var gl = this.renderer.gl;
|
971
|
+
var vao = this.renderer.createVao()
|
972
|
+
.addIndex(this.indexBuffer)
|
973
|
+
.addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0)
|
974
|
+
.addAttribute(vertexBuffer, attrs.aTrans1, gl.FLOAT, false, this.vertByteSize, 2 * 4)
|
975
|
+
.addAttribute(vertexBuffer, attrs.aTrans2, gl.FLOAT, false, this.vertByteSize, 5 * 4)
|
976
|
+
.addAttribute(vertexBuffer, attrs.aFrame, gl.FLOAT, false, this.vertByteSize, 8 * 4)
|
977
|
+
.addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 12 * 4);
|
978
|
+
if (attrs.aTextureId) {
|
979
|
+
vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 13 * 4);
|
980
|
+
}
|
981
|
+
return vao;
|
982
|
+
};
|
983
|
+
SpriteStrangeRenderer.prototype.fillVertices = function (float32View, uint32View, index, sprite, argb, textureId) {
|
984
|
+
var vertexData = sprite.vertexData;
|
985
|
+
var tex = sprite._texture;
|
986
|
+
var w = tex.orig.width;
|
987
|
+
var h = tex.orig.height;
|
988
|
+
var ax = sprite._anchor._x;
|
989
|
+
var ay = sprite._anchor._y;
|
990
|
+
var frame = tex._frame;
|
991
|
+
var aTrans = sprite.aTrans;
|
992
|
+
for (var i = 0; i < 4; i++) {
|
993
|
+
float32View[index] = vertexData[i * 2];
|
994
|
+
float32View[index + 1] = vertexData[i * 2 + 1];
|
995
|
+
float32View[index + 2] = aTrans.a;
|
996
|
+
float32View[index + 3] = aTrans.c;
|
997
|
+
float32View[index + 4] = aTrans.tx;
|
998
|
+
float32View[index + 5] = aTrans.b;
|
999
|
+
float32View[index + 6] = aTrans.d;
|
1000
|
+
float32View[index + 7] = aTrans.ty;
|
1001
|
+
float32View[index + 8] = frame.x;
|
1002
|
+
float32View[index + 9] = frame.y;
|
1003
|
+
float32View[index + 10] = frame.x + frame.width;
|
1004
|
+
float32View[index + 11] = frame.y + frame.height;
|
1005
|
+
uint32View[index + 12] = argb;
|
1006
|
+
float32View[index + 13] = textureId;
|
1007
|
+
index += 14;
|
1008
|
+
}
|
1009
|
+
};
|
1010
|
+
return SpriteStrangeRenderer;
|
1011
|
+
}(MultiTextureSpriteRenderer));
|
1012
|
+
PIXI.WebGLRenderer.registerPlugin('sprite_strange', SpriteStrangeRenderer);
|
1013
|
+
})(pixi_projection || (pixi_projection = {}));
|
1014
|
+
var pixi_projection;
|
1015
|
+
(function (pixi_projection) {
|
1016
|
+
var tempMat = new PIXI.Matrix();
|
1017
|
+
var tempRect = new PIXI.Rectangle();
|
1018
|
+
var tempPoint = new PIXI.Point();
|
1019
|
+
var StrangeSurface = (function (_super) {
|
1020
|
+
__extends(StrangeSurface, _super);
|
1021
|
+
function StrangeSurface() {
|
1022
|
+
var _this = _super.call(this) || this;
|
1023
|
+
_this.params = [0, 0, NaN, NaN];
|
1024
|
+
return _this;
|
1025
|
+
}
|
1026
|
+
StrangeSurface.prototype.clear = function () {
|
1027
|
+
var p = this.params;
|
1028
|
+
p[0] = 0;
|
1029
|
+
p[1] = 0;
|
1030
|
+
p[2] = NaN;
|
1031
|
+
p[3] = NaN;
|
1032
|
+
};
|
1033
|
+
StrangeSurface.prototype.setAxisX = function (pos, factor, outTransform) {
|
1034
|
+
var x = pos.x, y = pos.y;
|
1035
|
+
var d = Math.sqrt(x * x + y * y);
|
1036
|
+
var rot = outTransform.rotation;
|
1037
|
+
if (rot !== 0) {
|
1038
|
+
outTransform.skew._x -= rot;
|
1039
|
+
outTransform.skew._y += rot;
|
1040
|
+
outTransform.rotation = 0;
|
1041
|
+
}
|
1042
|
+
outTransform.skew.y = Math.atan2(y, x);
|
1043
|
+
var p = this.params;
|
1044
|
+
if (factor !== 0) {
|
1045
|
+
p[2] = -d * factor;
|
1046
|
+
}
|
1047
|
+
else {
|
1048
|
+
p[2] = NaN;
|
1049
|
+
}
|
1050
|
+
this._calc01();
|
1051
|
+
};
|
1052
|
+
StrangeSurface.prototype.setAxisY = function (pos, factor, outTransform) {
|
1053
|
+
var x = pos.x, y = pos.y;
|
1054
|
+
var d = Math.sqrt(x * x + y * y);
|
1055
|
+
var rot = outTransform.rotation;
|
1056
|
+
if (rot !== 0) {
|
1057
|
+
outTransform.skew._x -= rot;
|
1058
|
+
outTransform.skew._y += rot;
|
1059
|
+
outTransform.rotation = 0;
|
1060
|
+
}
|
1061
|
+
outTransform.skew.x = -Math.atan2(y, x) + Math.PI / 2;
|
1062
|
+
var p = this.params;
|
1063
|
+
if (factor !== 0) {
|
1064
|
+
p[3] = -d * factor;
|
1065
|
+
}
|
1066
|
+
else {
|
1067
|
+
p[3] = NaN;
|
1068
|
+
}
|
1069
|
+
this._calc01();
|
1070
|
+
};
|
1071
|
+
StrangeSurface.prototype._calc01 = function () {
|
1072
|
+
var p = this.params;
|
1073
|
+
if (isNaN(p[2])) {
|
1074
|
+
p[1] = 0;
|
1075
|
+
if (isNaN(p[3])) {
|
1076
|
+
p[0] = 0;
|
1077
|
+
}
|
1078
|
+
else {
|
1079
|
+
p[0] = 1.0 / p[3];
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
else {
|
1083
|
+
if (isNaN(p[3])) {
|
1084
|
+
p[0] = 0;
|
1085
|
+
p[1] = 1.0 / p[2];
|
1086
|
+
}
|
1087
|
+
else {
|
1088
|
+
var d = 1.0 - p[2] * p[3];
|
1089
|
+
p[0] = (1.0 - p[2]) / d;
|
1090
|
+
p[1] = (1.0 - p[3]) / d;
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
};
|
1094
|
+
StrangeSurface.prototype.apply = function (pos, newPos) {
|
1095
|
+
newPos = newPos || new PIXI.Point();
|
1096
|
+
var aleph = this.params[0], bet = this.params[1], A = this.params[2], B = this.params[3];
|
1097
|
+
var u = pos.x, v = pos.y;
|
1098
|
+
if (aleph === 0.0) {
|
1099
|
+
newPos.y = v * (1 + u * bet);
|
1100
|
+
newPos.x = u;
|
1101
|
+
}
|
1102
|
+
else if (bet === 0.0) {
|
1103
|
+
newPos.x = u * (1 + v * aleph);
|
1104
|
+
newPos.y = v;
|
1105
|
+
}
|
1106
|
+
else {
|
1107
|
+
var D = A * B - v * u;
|
1108
|
+
newPos.x = A * u * (B + v) / D;
|
1109
|
+
newPos.y = B * v * (A + u) / D;
|
1110
|
+
}
|
1111
|
+
return newPos;
|
1112
|
+
};
|
1113
|
+
StrangeSurface.prototype.applyInverse = function (pos, newPos) {
|
1114
|
+
newPos = newPos || new PIXI.Point();
|
1115
|
+
var aleph = this.params[0], bet = this.params[1], A = this.params[2], B = this.params[3];
|
1116
|
+
var x = pos.x, y = pos.y;
|
1117
|
+
if (aleph === 0.0) {
|
1118
|
+
newPos.y = y / (1 + x * bet);
|
1119
|
+
newPos.x = x;
|
1120
|
+
}
|
1121
|
+
else if (bet === 0.0) {
|
1122
|
+
newPos.x = x * (1 + y * aleph);
|
1123
|
+
newPos.y = y;
|
1124
|
+
}
|
1125
|
+
else {
|
1126
|
+
newPos.x = x * (bet + 1) / (bet + 1 + y * aleph);
|
1127
|
+
newPos.y = y * (aleph + 1) / (aleph + 1 + x * bet);
|
1128
|
+
}
|
1129
|
+
return newPos;
|
1130
|
+
};
|
1131
|
+
StrangeSurface.prototype.mapSprite = function (sprite, quad, outTransform) {
|
1132
|
+
var tex = sprite.texture;
|
1133
|
+
tempRect.x = -sprite.anchor.x * tex.orig.width;
|
1134
|
+
tempRect.y = -sprite.anchor.y * tex.orig.height;
|
1135
|
+
tempRect.width = tex.orig.width;
|
1136
|
+
tempRect.height = tex.orig.height;
|
1137
|
+
return this.mapQuad(tempRect, quad, outTransform || sprite.transform);
|
1138
|
+
};
|
1139
|
+
StrangeSurface.prototype.mapQuad = function (rect, quad, outTransform) {
|
1140
|
+
var ax = -rect.x / rect.width;
|
1141
|
+
var ay = -rect.y / rect.height;
|
1142
|
+
var ax2 = (1.0 - rect.x) / rect.width;
|
1143
|
+
var ay2 = (1.0 - rect.y) / rect.height;
|
1144
|
+
var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax);
|
1145
|
+
var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax);
|
1146
|
+
var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2);
|
1147
|
+
var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2);
|
1148
|
+
var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax);
|
1149
|
+
var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax);
|
1150
|
+
var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2);
|
1151
|
+
var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2);
|
1152
|
+
var x00 = up1x * (1.0 - ay) + down1x * ay;
|
1153
|
+
var y00 = up1y * (1.0 - ay) + down1y * ay;
|
1154
|
+
var x10 = up2x * (1.0 - ay) + down2x * ay;
|
1155
|
+
var y10 = up2y * (1.0 - ay) + down2y * ay;
|
1156
|
+
var x01 = up1x * (1.0 - ay2) + down1x * ay2;
|
1157
|
+
var y01 = up1y * (1.0 - ay2) + down1y * ay2;
|
1158
|
+
var x11 = up2x * (1.0 - ay2) + down2x * ay2;
|
1159
|
+
var y11 = up2y * (1.0 - ay2) + down2y * ay2;
|
1160
|
+
var mat = tempMat;
|
1161
|
+
mat.tx = x00;
|
1162
|
+
mat.ty = y00;
|
1163
|
+
mat.a = x10 - x00;
|
1164
|
+
mat.b = y10 - y00;
|
1165
|
+
mat.c = x01 - x00;
|
1166
|
+
mat.d = y01 - y00;
|
1167
|
+
tempPoint.set(x11, y11);
|
1168
|
+
mat.applyInverse(tempPoint, tempPoint);
|
1169
|
+
outTransform.setFromMatrix(mat);
|
1170
|
+
return this;
|
1171
|
+
};
|
1172
|
+
StrangeSurface.prototype.fillUniforms = function (uniforms) {
|
1173
|
+
var params = this.params;
|
1174
|
+
var distortion = uniforms.params || new Float32Array([0, 0, 0, 0]);
|
1175
|
+
uniforms.params = distortion;
|
1176
|
+
distortion[0] = params[0];
|
1177
|
+
distortion[1] = params[1];
|
1178
|
+
distortion[2] = params[2];
|
1179
|
+
distortion[3] = params[3];
|
1180
|
+
};
|
1181
|
+
return StrangeSurface;
|
1182
|
+
}(pixi_projection.Surface));
|
1183
|
+
pixi_projection.StrangeSurface = StrangeSurface;
|
1184
|
+
})(pixi_projection || (pixi_projection = {}));
|
1185
|
+
var pixi_projection;
|
1186
|
+
(function (pixi_projection) {
|
1187
|
+
var Sprite2s = (function (_super) {
|
1188
|
+
__extends(Sprite2s, _super);
|
1189
|
+
function Sprite2s(texture) {
|
1190
|
+
var _this = _super.call(this, texture) || this;
|
1191
|
+
_this.aTrans = new PIXI.Matrix();
|
1192
|
+
_this.proj = new pixi_projection.ProjectionSurface(_this.transform);
|
1193
|
+
_this.pluginName = 'sprite_bilinear';
|
1194
|
+
return _this;
|
1195
|
+
}
|
1196
|
+
Sprite2s.prototype._calculateBounds = function () {
|
1197
|
+
this.calculateTrimmedVertices();
|
1198
|
+
this._bounds.addQuad(this.vertexTrimmedData);
|
1199
|
+
};
|
1200
|
+
Sprite2s.prototype.calculateVertices = function () {
|
1201
|
+
var wid = this.transform._worldID;
|
1202
|
+
var tuid = this._texture._updateID;
|
1203
|
+
if (this._transformID === wid && this._textureID === tuid) {
|
1204
|
+
return;
|
1205
|
+
}
|
1206
|
+
this._transformID = wid;
|
1207
|
+
this._textureID = tuid;
|
1208
|
+
var texture = this._texture;
|
1209
|
+
var vertexData = this.vertexData;
|
1210
|
+
var trim = texture.trim;
|
1211
|
+
var orig = texture.orig;
|
1212
|
+
var anchor = this._anchor;
|
1213
|
+
var w0 = 0;
|
1214
|
+
var w1 = 0;
|
1215
|
+
var h0 = 0;
|
1216
|
+
var h1 = 0;
|
1217
|
+
if (trim) {
|
1218
|
+
w1 = trim.x - (anchor._x * orig.width);
|
1219
|
+
w0 = w1 + trim.width;
|
1220
|
+
h1 = trim.y - (anchor._y * orig.height);
|
1221
|
+
h0 = h1 + trim.height;
|
1222
|
+
}
|
1223
|
+
else {
|
1224
|
+
w1 = -anchor._x * orig.width;
|
1225
|
+
w0 = w1 + orig.width;
|
1226
|
+
h1 = -anchor._y * orig.height;
|
1227
|
+
h0 = h1 + orig.height;
|
1228
|
+
}
|
1229
|
+
if (this.proj._surface) {
|
1230
|
+
vertexData[0] = w1;
|
1231
|
+
vertexData[1] = h1;
|
1232
|
+
vertexData[2] = w0;
|
1233
|
+
vertexData[3] = h1;
|
1234
|
+
vertexData[4] = w0;
|
1235
|
+
vertexData[5] = h0;
|
1236
|
+
vertexData[6] = w1;
|
1237
|
+
vertexData[7] = h0;
|
1238
|
+
this.proj._surface.boundsQuad(vertexData, vertexData);
|
1239
|
+
}
|
1240
|
+
else {
|
1241
|
+
var wt = this.transform.worldTransform;
|
1242
|
+
var a = wt.a;
|
1243
|
+
var b = wt.b;
|
1244
|
+
var c = wt.c;
|
1245
|
+
var d = wt.d;
|
1246
|
+
var tx = wt.tx;
|
1247
|
+
var ty = wt.ty;
|
1248
|
+
vertexData[0] = (a * w1) + (c * h1) + tx;
|
1249
|
+
vertexData[1] = (d * h1) + (b * w1) + ty;
|
1250
|
+
vertexData[2] = (a * w0) + (c * h1) + tx;
|
1251
|
+
vertexData[3] = (d * h1) + (b * w0) + ty;
|
1252
|
+
vertexData[4] = (a * w0) + (c * h0) + tx;
|
1253
|
+
vertexData[5] = (d * h0) + (b * w0) + ty;
|
1254
|
+
vertexData[6] = (a * w1) + (c * h0) + tx;
|
1255
|
+
vertexData[7] = (d * h0) + (b * w1) + ty;
|
1256
|
+
if (this.proj._activeProjection) {
|
1257
|
+
this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData);
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
if (!texture.transform) {
|
1261
|
+
texture.transform = new PIXI.TextureMatrix(texture);
|
1262
|
+
}
|
1263
|
+
texture.transform.update();
|
1264
|
+
var aTrans = this.aTrans;
|
1265
|
+
aTrans.set(orig.width, 0, 0, orig.height, w1, h1);
|
1266
|
+
if (this.proj._surface === null) {
|
1267
|
+
aTrans.prepend(this.transform.worldTransform);
|
1268
|
+
}
|
1269
|
+
aTrans.invert();
|
1270
|
+
aTrans.prepend(texture.transform.mapCoord);
|
1271
|
+
};
|
1272
|
+
Sprite2s.prototype.calculateTrimmedVertices = function () {
|
1273
|
+
var wid = this.transform._worldID;
|
1274
|
+
var tuid = this._texture._updateID;
|
1275
|
+
if (!this.vertexTrimmedData) {
|
1276
|
+
this.vertexTrimmedData = new Float32Array(8);
|
1277
|
+
}
|
1278
|
+
else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) {
|
1279
|
+
return;
|
1280
|
+
}
|
1281
|
+
this._transformTrimmedID = wid;
|
1282
|
+
this._textureTrimmedID = tuid;
|
1283
|
+
var texture = this._texture;
|
1284
|
+
var vertexData = this.vertexTrimmedData;
|
1285
|
+
var orig = texture.orig;
|
1286
|
+
var anchor = this._anchor;
|
1287
|
+
var w1 = -anchor._x * orig.width;
|
1288
|
+
var w0 = w1 + orig.width;
|
1289
|
+
var h1 = -anchor._y * orig.height;
|
1290
|
+
var h0 = h1 + orig.height;
|
1291
|
+
if (this.proj._surface) {
|
1292
|
+
vertexData[0] = w1;
|
1293
|
+
vertexData[1] = h1;
|
1294
|
+
vertexData[2] = w0;
|
1295
|
+
vertexData[3] = h1;
|
1296
|
+
vertexData[4] = w0;
|
1297
|
+
vertexData[5] = h0;
|
1298
|
+
vertexData[6] = w1;
|
1299
|
+
vertexData[7] = h0;
|
1300
|
+
this.proj._surface.boundsQuad(vertexData, vertexData, this.transform.worldTransform);
|
1301
|
+
}
|
1302
|
+
else {
|
1303
|
+
var wt = this.transform.worldTransform;
|
1304
|
+
var a = wt.a;
|
1305
|
+
var b = wt.b;
|
1306
|
+
var c = wt.c;
|
1307
|
+
var d = wt.d;
|
1308
|
+
var tx = wt.tx;
|
1309
|
+
var ty = wt.ty;
|
1310
|
+
vertexData[0] = (a * w1) + (c * h1) + tx;
|
1311
|
+
vertexData[1] = (d * h1) + (b * w1) + ty;
|
1312
|
+
vertexData[2] = (a * w0) + (c * h1) + tx;
|
1313
|
+
vertexData[3] = (d * h1) + (b * w0) + ty;
|
1314
|
+
vertexData[4] = (a * w0) + (c * h0) + tx;
|
1315
|
+
vertexData[5] = (d * h0) + (b * w0) + ty;
|
1316
|
+
vertexData[6] = (a * w1) + (c * h0) + tx;
|
1317
|
+
vertexData[7] = (d * h0) + (b * w1) + ty;
|
1318
|
+
if (this.proj._activeProjection) {
|
1319
|
+
this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData, this.proj._activeProjection.legacy.worldTransform);
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
};
|
1323
|
+
Object.defineProperty(Sprite2s.prototype, "worldTransform", {
|
1324
|
+
get: function () {
|
1325
|
+
return this.proj;
|
1326
|
+
},
|
1327
|
+
enumerable: true,
|
1328
|
+
configurable: true
|
1329
|
+
});
|
1330
|
+
return Sprite2s;
|
1331
|
+
}(PIXI.Sprite));
|
1332
|
+
pixi_projection.Sprite2s = Sprite2s;
|
1333
|
+
})(pixi_projection || (pixi_projection = {}));
|
1334
|
+
var pixi_projection;
|
1335
|
+
(function (pixi_projection) {
|
1336
|
+
var Text2s = (function (_super) {
|
1337
|
+
__extends(Text2s, _super);
|
1338
|
+
function Text2s(text, style, canvas) {
|
1339
|
+
var _this = _super.call(this, text, style, canvas) || this;
|
1340
|
+
_this.aTrans = new PIXI.Matrix();
|
1341
|
+
_this.proj = new pixi_projection.ProjectionSurface(_this.transform);
|
1342
|
+
_this.pluginName = 'sprite_bilinear';
|
1343
|
+
return _this;
|
1344
|
+
}
|
1345
|
+
Object.defineProperty(Text2s.prototype, "worldTransform", {
|
1346
|
+
get: function () {
|
1347
|
+
return this.proj;
|
1348
|
+
},
|
1349
|
+
enumerable: true,
|
1350
|
+
configurable: true
|
1351
|
+
});
|
1352
|
+
return Text2s;
|
1353
|
+
}(PIXI.Text));
|
1354
|
+
pixi_projection.Text2s = Text2s;
|
1355
|
+
Text2s.prototype.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices;
|
1356
|
+
Text2s.prototype.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices;
|
1357
|
+
Text2s.prototype._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds;
|
1358
|
+
})(pixi_projection || (pixi_projection = {}));
|
1359
|
+
var pixi_projection;
|
1360
|
+
(function (pixi_projection) {
|
1361
|
+
PIXI.Sprite.prototype.convertTo2s = function () {
|
1362
|
+
if (this.proj)
|
1363
|
+
return;
|
1364
|
+
this.pluginName = 'sprite_bilinear';
|
1365
|
+
this.aTrans = new PIXI.Matrix();
|
1366
|
+
this.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices;
|
1367
|
+
this.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices;
|
1368
|
+
this._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds;
|
1369
|
+
PIXI.Container.prototype.convertTo2s.call(this);
|
1370
|
+
};
|
1371
|
+
PIXI.Container.prototype.convertTo2s = function () {
|
1372
|
+
if (this.proj)
|
1373
|
+
return;
|
1374
|
+
this.proj = new pixi_projection.Projection2d(this.transform);
|
1375
|
+
Object.defineProperty(this, "worldTransform", {
|
1376
|
+
get: function () {
|
1377
|
+
return this.proj;
|
1378
|
+
},
|
1379
|
+
enumerable: true,
|
1380
|
+
configurable: true
|
1381
|
+
});
|
1382
|
+
};
|
1383
|
+
PIXI.Container.prototype.convertSubtreeTo2s = function () {
|
1384
|
+
this.convertTo2s();
|
1385
|
+
for (var i = 0; i < this.children.length; i++) {
|
1386
|
+
this.children[i].convertSubtreeTo2s();
|
1387
|
+
}
|
1388
|
+
};
|
1389
|
+
})(pixi_projection || (pixi_projection = {}));
|
1390
|
+
var pixi_projection;
|
1391
|
+
(function (pixi_projection) {
|
1392
|
+
function container2dWorldTransform() {
|
1393
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
1394
|
+
}
|
1395
|
+
pixi_projection.container2dWorldTransform = container2dWorldTransform;
|
1396
|
+
var Container2d = (function (_super) {
|
1397
|
+
__extends(Container2d, _super);
|
1398
|
+
function Container2d() {
|
1399
|
+
var _this = _super.call(this) || this;
|
1400
|
+
_this.proj = new pixi_projection.Projection2d(_this.transform);
|
1401
|
+
return _this;
|
1402
|
+
}
|
1403
|
+
Container2d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
1404
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
1405
|
+
if (from) {
|
1406
|
+
position = from.toGlobal(position, point, skipUpdate);
|
1407
|
+
}
|
1408
|
+
if (!skipUpdate) {
|
1409
|
+
this._recursivePostUpdateTransform();
|
1410
|
+
}
|
1411
|
+
if (step >= pixi_projection.TRANSFORM_STEP.PROJ) {
|
1412
|
+
if (!skipUpdate) {
|
1413
|
+
this.displayObjectUpdateTransform();
|
1414
|
+
}
|
1415
|
+
if (this.proj.affine) {
|
1416
|
+
return this.transform.worldTransform.applyInverse(point, point);
|
1417
|
+
}
|
1418
|
+
return this.proj.world.applyInverse(point, point);
|
1419
|
+
}
|
1420
|
+
if (this.parent) {
|
1421
|
+
point = this.parent.worldTransform.applyInverse(position, point);
|
1422
|
+
}
|
1423
|
+
else {
|
1424
|
+
point.copy(position);
|
1425
|
+
}
|
1426
|
+
if (step === pixi_projection.TRANSFORM_STEP.NONE) {
|
1427
|
+
return point;
|
1428
|
+
}
|
1429
|
+
return this.transform.localTransform.applyInverse(point, point);
|
1430
|
+
};
|
1431
|
+
Object.defineProperty(Container2d.prototype, "worldTransform", {
|
1432
|
+
get: function () {
|
1433
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
1434
|
+
},
|
1435
|
+
enumerable: true,
|
1436
|
+
configurable: true
|
1437
|
+
});
|
1438
|
+
return Container2d;
|
1439
|
+
}(PIXI.Container));
|
1440
|
+
pixi_projection.Container2d = Container2d;
|
1441
|
+
pixi_projection.container2dToLocal = Container2d.prototype.toLocal;
|
1442
|
+
})(pixi_projection || (pixi_projection = {}));
|
1443
|
+
var pixi_projection;
|
1444
|
+
(function (pixi_projection) {
|
1445
|
+
var Point = PIXI.Point;
|
1446
|
+
var mat3id = [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
1447
|
+
var AFFINE;
|
1448
|
+
(function (AFFINE) {
|
1449
|
+
AFFINE[AFFINE["NONE"] = 0] = "NONE";
|
1450
|
+
AFFINE[AFFINE["FREE"] = 1] = "FREE";
|
1451
|
+
AFFINE[AFFINE["AXIS_X"] = 2] = "AXIS_X";
|
1452
|
+
AFFINE[AFFINE["AXIS_Y"] = 3] = "AXIS_Y";
|
1453
|
+
AFFINE[AFFINE["POINT"] = 4] = "POINT";
|
1454
|
+
})(AFFINE = pixi_projection.AFFINE || (pixi_projection.AFFINE = {}));
|
1455
|
+
var Matrix2d = (function () {
|
1456
|
+
function Matrix2d(backingArray) {
|
1457
|
+
this.floatArray = null;
|
1458
|
+
this.mat3 = new Float64Array(backingArray || mat3id);
|
1459
|
+
}
|
1460
|
+
Object.defineProperty(Matrix2d.prototype, "a", {
|
1461
|
+
get: function () {
|
1462
|
+
return this.mat3[0] / this.mat3[8];
|
1463
|
+
},
|
1464
|
+
set: function (value) {
|
1465
|
+
this.mat3[0] = value * this.mat3[8];
|
1466
|
+
},
|
1467
|
+
enumerable: true,
|
1468
|
+
configurable: true
|
1469
|
+
});
|
1470
|
+
Object.defineProperty(Matrix2d.prototype, "b", {
|
1471
|
+
get: function () {
|
1472
|
+
return this.mat3[1] / this.mat3[8];
|
1473
|
+
},
|
1474
|
+
set: function (value) {
|
1475
|
+
this.mat3[1] = value * this.mat3[8];
|
1476
|
+
},
|
1477
|
+
enumerable: true,
|
1478
|
+
configurable: true
|
1479
|
+
});
|
1480
|
+
Object.defineProperty(Matrix2d.prototype, "c", {
|
1481
|
+
get: function () {
|
1482
|
+
return this.mat3[3] / this.mat3[8];
|
1483
|
+
},
|
1484
|
+
set: function (value) {
|
1485
|
+
this.mat3[3] = value * this.mat3[8];
|
1486
|
+
},
|
1487
|
+
enumerable: true,
|
1488
|
+
configurable: true
|
1489
|
+
});
|
1490
|
+
Object.defineProperty(Matrix2d.prototype, "d", {
|
1491
|
+
get: function () {
|
1492
|
+
return this.mat3[4] / this.mat3[8];
|
1493
|
+
},
|
1494
|
+
set: function (value) {
|
1495
|
+
this.mat3[4] = value * this.mat3[8];
|
1496
|
+
},
|
1497
|
+
enumerable: true,
|
1498
|
+
configurable: true
|
1499
|
+
});
|
1500
|
+
Object.defineProperty(Matrix2d.prototype, "tx", {
|
1501
|
+
get: function () {
|
1502
|
+
return this.mat3[6] / this.mat3[8];
|
1503
|
+
},
|
1504
|
+
set: function (value) {
|
1505
|
+
this.mat3[6] = value * this.mat3[8];
|
1506
|
+
},
|
1507
|
+
enumerable: true,
|
1508
|
+
configurable: true
|
1509
|
+
});
|
1510
|
+
Object.defineProperty(Matrix2d.prototype, "ty", {
|
1511
|
+
get: function () {
|
1512
|
+
return this.mat3[7] / this.mat3[8];
|
1513
|
+
},
|
1514
|
+
set: function (value) {
|
1515
|
+
this.mat3[7] = value * this.mat3[8];
|
1516
|
+
},
|
1517
|
+
enumerable: true,
|
1518
|
+
configurable: true
|
1519
|
+
});
|
1520
|
+
Matrix2d.prototype.set = function (a, b, c, d, tx, ty) {
|
1521
|
+
var mat3 = this.mat3;
|
1522
|
+
mat3[0] = a;
|
1523
|
+
mat3[1] = b;
|
1524
|
+
mat3[2] = 0;
|
1525
|
+
mat3[3] = c;
|
1526
|
+
mat3[4] = d;
|
1527
|
+
mat3[5] = 0;
|
1528
|
+
mat3[6] = tx;
|
1529
|
+
mat3[7] = ty;
|
1530
|
+
mat3[8] = 1;
|
1531
|
+
return this;
|
1532
|
+
};
|
1533
|
+
Matrix2d.prototype.toArray = function (transpose, out) {
|
1534
|
+
if (!this.floatArray) {
|
1535
|
+
this.floatArray = new Float32Array(9);
|
1536
|
+
}
|
1537
|
+
var array = out || this.floatArray;
|
1538
|
+
var mat3 = this.mat3;
|
1539
|
+
if (transpose) {
|
1540
|
+
array[0] = mat3[0];
|
1541
|
+
array[1] = mat3[1];
|
1542
|
+
array[2] = mat3[2];
|
1543
|
+
array[3] = mat3[3];
|
1544
|
+
array[4] = mat3[4];
|
1545
|
+
array[5] = mat3[5];
|
1546
|
+
array[6] = mat3[6];
|
1547
|
+
array[7] = mat3[7];
|
1548
|
+
array[8] = mat3[8];
|
1549
|
+
}
|
1550
|
+
else {
|
1551
|
+
array[0] = mat3[0];
|
1552
|
+
array[1] = mat3[3];
|
1553
|
+
array[2] = mat3[6];
|
1554
|
+
array[3] = mat3[1];
|
1555
|
+
array[4] = mat3[4];
|
1556
|
+
array[5] = mat3[7];
|
1557
|
+
array[6] = mat3[2];
|
1558
|
+
array[7] = mat3[5];
|
1559
|
+
array[8] = mat3[8];
|
1560
|
+
}
|
1561
|
+
return array;
|
1562
|
+
};
|
1563
|
+
Matrix2d.prototype.apply = function (pos, newPos) {
|
1564
|
+
newPos = newPos || new PIXI.Point();
|
1565
|
+
var mat3 = this.mat3;
|
1566
|
+
var x = pos.x;
|
1567
|
+
var y = pos.y;
|
1568
|
+
var z = 1.0 / (mat3[2] * x + mat3[5] * y + mat3[8]);
|
1569
|
+
newPos.x = z * (mat3[0] * x + mat3[3] * y + mat3[6]);
|
1570
|
+
newPos.y = z * (mat3[1] * x + mat3[4] * y + mat3[7]);
|
1571
|
+
return newPos;
|
1572
|
+
};
|
1573
|
+
Matrix2d.prototype.translate = function (tx, ty) {
|
1574
|
+
var mat3 = this.mat3;
|
1575
|
+
mat3[0] += tx * mat3[2];
|
1576
|
+
mat3[1] += ty * mat3[2];
|
1577
|
+
mat3[3] += tx * mat3[5];
|
1578
|
+
mat3[4] += ty * mat3[5];
|
1579
|
+
mat3[6] += tx * mat3[8];
|
1580
|
+
mat3[7] += ty * mat3[8];
|
1581
|
+
return this;
|
1582
|
+
};
|
1583
|
+
Matrix2d.prototype.scale = function (x, y) {
|
1584
|
+
var mat3 = this.mat3;
|
1585
|
+
mat3[0] *= x;
|
1586
|
+
mat3[1] *= y;
|
1587
|
+
mat3[3] *= x;
|
1588
|
+
mat3[4] *= y;
|
1589
|
+
mat3[6] *= x;
|
1590
|
+
mat3[7] *= y;
|
1591
|
+
return this;
|
1592
|
+
};
|
1593
|
+
Matrix2d.prototype.scaleAndTranslate = function (scaleX, scaleY, tx, ty) {
|
1594
|
+
var mat3 = this.mat3;
|
1595
|
+
mat3[0] = scaleX * mat3[0] + tx * mat3[2];
|
1596
|
+
mat3[1] = scaleY * mat3[1] + ty * mat3[2];
|
1597
|
+
mat3[3] = scaleX * mat3[3] + tx * mat3[5];
|
1598
|
+
mat3[4] = scaleY * mat3[4] + ty * mat3[5];
|
1599
|
+
mat3[6] = scaleX * mat3[6] + tx * mat3[8];
|
1600
|
+
mat3[7] = scaleY * mat3[7] + ty * mat3[8];
|
1601
|
+
};
|
1602
|
+
Matrix2d.prototype.applyInverse = function (pos, newPos) {
|
1603
|
+
newPos = newPos || new Point();
|
1604
|
+
var a = this.mat3;
|
1605
|
+
var x = pos.x;
|
1606
|
+
var y = pos.y;
|
1607
|
+
var a00 = a[0], a01 = a[3], a02 = a[6], a10 = a[1], a11 = a[4], a12 = a[7], a20 = a[2], a21 = a[5], a22 = a[8];
|
1608
|
+
var newX = (a22 * a11 - a12 * a21) * x + (-a22 * a01 + a02 * a21) * y + (a12 * a01 - a02 * a11);
|
1609
|
+
var newY = (-a22 * a10 + a12 * a20) * x + (a22 * a00 - a02 * a20) * y + (-a12 * a00 + a02 * a10);
|
1610
|
+
var newZ = (a21 * a10 - a11 * a20) * x + (-a21 * a00 + a01 * a20) * y + (a11 * a00 - a01 * a10);
|
1611
|
+
newPos.x = newX / newZ;
|
1612
|
+
newPos.y = newY / newZ;
|
1613
|
+
return newPos;
|
1614
|
+
};
|
1615
|
+
Matrix2d.prototype.invert = function () {
|
1616
|
+
var a = this.mat3;
|
1617
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b01 = a22 * a11 - a12 * a21, b11 = -a22 * a10 + a12 * a20, b21 = a21 * a10 - a11 * a20;
|
1618
|
+
var det = a00 * b01 + a01 * b11 + a02 * b21;
|
1619
|
+
if (!det) {
|
1620
|
+
return this;
|
1621
|
+
}
|
1622
|
+
det = 1.0 / det;
|
1623
|
+
a[0] = b01 * det;
|
1624
|
+
a[1] = (-a22 * a01 + a02 * a21) * det;
|
1625
|
+
a[2] = (a12 * a01 - a02 * a11) * det;
|
1626
|
+
a[3] = b11 * det;
|
1627
|
+
a[4] = (a22 * a00 - a02 * a20) * det;
|
1628
|
+
a[5] = (-a12 * a00 + a02 * a10) * det;
|
1629
|
+
a[6] = b21 * det;
|
1630
|
+
a[7] = (-a21 * a00 + a01 * a20) * det;
|
1631
|
+
a[8] = (a11 * a00 - a01 * a10) * det;
|
1632
|
+
return this;
|
1633
|
+
};
|
1634
|
+
Matrix2d.prototype.identity = function () {
|
1635
|
+
var mat3 = this.mat3;
|
1636
|
+
mat3[0] = 1;
|
1637
|
+
mat3[1] = 0;
|
1638
|
+
mat3[2] = 0;
|
1639
|
+
mat3[3] = 0;
|
1640
|
+
mat3[4] = 1;
|
1641
|
+
mat3[5] = 0;
|
1642
|
+
mat3[6] = 0;
|
1643
|
+
mat3[7] = 0;
|
1644
|
+
mat3[8] = 1;
|
1645
|
+
return this;
|
1646
|
+
};
|
1647
|
+
Matrix2d.prototype.clone = function () {
|
1648
|
+
return new Matrix2d(this.mat3);
|
1649
|
+
};
|
1650
|
+
Matrix2d.prototype.copyTo = function (matrix) {
|
1651
|
+
var mat3 = this.mat3;
|
1652
|
+
var ar2 = matrix.mat3;
|
1653
|
+
ar2[0] = mat3[0];
|
1654
|
+
ar2[1] = mat3[1];
|
1655
|
+
ar2[2] = mat3[2];
|
1656
|
+
ar2[3] = mat3[3];
|
1657
|
+
ar2[4] = mat3[4];
|
1658
|
+
ar2[5] = mat3[5];
|
1659
|
+
ar2[6] = mat3[6];
|
1660
|
+
ar2[7] = mat3[7];
|
1661
|
+
ar2[8] = mat3[8];
|
1662
|
+
return matrix;
|
1663
|
+
};
|
1664
|
+
Matrix2d.prototype.copy = function (matrix, affine) {
|
1665
|
+
var mat3 = this.mat3;
|
1666
|
+
var d = 1.0 / mat3[8];
|
1667
|
+
var tx = mat3[6] * d, ty = mat3[7] * d;
|
1668
|
+
matrix.a = (mat3[0] - mat3[2] * tx) * d;
|
1669
|
+
matrix.b = (mat3[1] - mat3[2] * ty) * d;
|
1670
|
+
matrix.c = (mat3[3] - mat3[5] * tx) * d;
|
1671
|
+
matrix.d = (mat3[4] - mat3[5] * ty) * d;
|
1672
|
+
matrix.tx = tx;
|
1673
|
+
matrix.ty = ty;
|
1674
|
+
if (affine >= 2) {
|
1675
|
+
if (affine === AFFINE.POINT) {
|
1676
|
+
matrix.a = 1;
|
1677
|
+
matrix.b = 0;
|
1678
|
+
matrix.c = 0;
|
1679
|
+
matrix.d = 1;
|
1680
|
+
}
|
1681
|
+
else if (affine === AFFINE.AXIS_X) {
|
1682
|
+
matrix.c = -matrix.b;
|
1683
|
+
matrix.d = matrix.a;
|
1684
|
+
}
|
1685
|
+
else if (affine === AFFINE.AXIS_Y) {
|
1686
|
+
matrix.a = matrix.d;
|
1687
|
+
matrix.c = -matrix.b;
|
1688
|
+
}
|
1689
|
+
}
|
1690
|
+
};
|
1691
|
+
Matrix2d.prototype.copyFrom = function (matrix) {
|
1692
|
+
var mat3 = this.mat3;
|
1693
|
+
mat3[0] = matrix.a;
|
1694
|
+
mat3[1] = matrix.b;
|
1695
|
+
mat3[2] = 0;
|
1696
|
+
mat3[3] = matrix.c;
|
1697
|
+
mat3[4] = matrix.d;
|
1698
|
+
mat3[5] = 0;
|
1699
|
+
mat3[6] = matrix.tx;
|
1700
|
+
mat3[7] = matrix.ty;
|
1701
|
+
mat3[8] = 1.0;
|
1702
|
+
return this;
|
1703
|
+
};
|
1704
|
+
Matrix2d.prototype.setToMultLegacy = function (pt, lt) {
|
1705
|
+
var out = this.mat3;
|
1706
|
+
var b = lt.mat3;
|
1707
|
+
var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a20 = pt.tx, a21 = pt.ty, b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8];
|
1708
|
+
out[0] = b00 * a00 + b01 * a10 + b02 * a20;
|
1709
|
+
out[1] = b00 * a01 + b01 * a11 + b02 * a21;
|
1710
|
+
out[2] = b02;
|
1711
|
+
out[3] = b10 * a00 + b11 * a10 + b12 * a20;
|
1712
|
+
out[4] = b10 * a01 + b11 * a11 + b12 * a21;
|
1713
|
+
out[5] = b12;
|
1714
|
+
out[6] = b20 * a00 + b21 * a10 + b22 * a20;
|
1715
|
+
out[7] = b20 * a01 + b21 * a11 + b22 * a21;
|
1716
|
+
out[8] = b22;
|
1717
|
+
return this;
|
1718
|
+
};
|
1719
|
+
Matrix2d.prototype.setToMultLegacy2 = function (pt, lt) {
|
1720
|
+
var out = this.mat3;
|
1721
|
+
var a = pt.mat3;
|
1722
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b20 = lt.tx, b21 = lt.ty;
|
1723
|
+
out[0] = b00 * a00 + b01 * a10;
|
1724
|
+
out[1] = b00 * a01 + b01 * a11;
|
1725
|
+
out[2] = b00 * a02 + b01 * a12;
|
1726
|
+
out[3] = b10 * a00 + b11 * a10;
|
1727
|
+
out[4] = b10 * a01 + b11 * a11;
|
1728
|
+
out[5] = b10 * a02 + b11 * a12;
|
1729
|
+
out[6] = b20 * a00 + b21 * a10 + a20;
|
1730
|
+
out[7] = b20 * a01 + b21 * a11 + a21;
|
1731
|
+
out[8] = b20 * a02 + b21 * a12 + a22;
|
1732
|
+
return this;
|
1733
|
+
};
|
1734
|
+
Matrix2d.prototype.setToMult = function (pt, lt) {
|
1735
|
+
var out = this.mat3;
|
1736
|
+
var a = pt.mat3, b = lt.mat3;
|
1737
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8];
|
1738
|
+
out[0] = b00 * a00 + b01 * a10 + b02 * a20;
|
1739
|
+
out[1] = b00 * a01 + b01 * a11 + b02 * a21;
|
1740
|
+
out[2] = b00 * a02 + b01 * a12 + b02 * a22;
|
1741
|
+
out[3] = b10 * a00 + b11 * a10 + b12 * a20;
|
1742
|
+
out[4] = b10 * a01 + b11 * a11 + b12 * a21;
|
1743
|
+
out[5] = b10 * a02 + b11 * a12 + b12 * a22;
|
1744
|
+
out[6] = b20 * a00 + b21 * a10 + b22 * a20;
|
1745
|
+
out[7] = b20 * a01 + b21 * a11 + b22 * a21;
|
1746
|
+
out[8] = b20 * a02 + b21 * a12 + b22 * a22;
|
1747
|
+
return this;
|
1748
|
+
};
|
1749
|
+
Matrix2d.prototype.prepend = function (lt) {
|
1750
|
+
if (lt.mat3) {
|
1751
|
+
this.setToMult(lt, this);
|
1752
|
+
}
|
1753
|
+
else {
|
1754
|
+
this.setToMultLegacy(lt, this);
|
1755
|
+
}
|
1756
|
+
};
|
1757
|
+
Matrix2d.IDENTITY = new Matrix2d();
|
1758
|
+
Matrix2d.TEMP_MATRIX = new Matrix2d();
|
1759
|
+
return Matrix2d;
|
1760
|
+
}());
|
1761
|
+
pixi_projection.Matrix2d = Matrix2d;
|
1762
|
+
})(pixi_projection || (pixi_projection = {}));
|
1763
|
+
var pixi_projection;
|
1764
|
+
(function (pixi_projection) {
|
1765
|
+
var t0 = new PIXI.Point();
|
1766
|
+
var tt = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()];
|
1767
|
+
var tempRect = new PIXI.Rectangle();
|
1768
|
+
var tempMat = new pixi_projection.Matrix2d();
|
1769
|
+
var Projection2d = (function (_super) {
|
1770
|
+
__extends(Projection2d, _super);
|
1771
|
+
function Projection2d(legacy, enable) {
|
1772
|
+
var _this = _super.call(this, legacy, enable) || this;
|
1773
|
+
_this.matrix = new pixi_projection.Matrix2d();
|
1774
|
+
_this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0);
|
1775
|
+
_this.reverseLocalOrder = false;
|
1776
|
+
_this.local = new pixi_projection.Matrix2d();
|
1777
|
+
_this.world = new pixi_projection.Matrix2d();
|
1778
|
+
return _this;
|
1779
|
+
}
|
1780
|
+
Projection2d.prototype.onChange = function () {
|
1781
|
+
var pivot = this.pivot;
|
1782
|
+
var mat3 = this.matrix.mat3;
|
1783
|
+
mat3[6] = -(pivot._x * mat3[0] + pivot._y * mat3[3]);
|
1784
|
+
mat3[7] = -(pivot._x * mat3[1] + pivot._y * mat3[4]);
|
1785
|
+
this._projID++;
|
1786
|
+
};
|
1787
|
+
Projection2d.prototype.setAxisX = function (p, factor) {
|
1788
|
+
if (factor === void 0) { factor = 1; }
|
1789
|
+
var x = p.x, y = p.y;
|
1790
|
+
var d = Math.sqrt(x * x + y * y);
|
1791
|
+
var mat3 = this.matrix.mat3;
|
1792
|
+
mat3[0] = x / d;
|
1793
|
+
mat3[1] = y / d;
|
1794
|
+
mat3[2] = factor / d;
|
1795
|
+
this.onChange();
|
1796
|
+
};
|
1797
|
+
Projection2d.prototype.setAxisY = function (p, factor) {
|
1798
|
+
if (factor === void 0) { factor = 1; }
|
1799
|
+
var x = p.x, y = p.y;
|
1800
|
+
var d = Math.sqrt(x * x + y * y);
|
1801
|
+
var mat3 = this.matrix.mat3;
|
1802
|
+
mat3[3] = x / d;
|
1803
|
+
mat3[4] = y / d;
|
1804
|
+
mat3[5] = factor / d;
|
1805
|
+
this.onChange();
|
1806
|
+
};
|
1807
|
+
Projection2d.prototype.mapSprite = function (sprite, quad) {
|
1808
|
+
var tex = sprite.texture;
|
1809
|
+
tempRect.x = -sprite.anchor.x * tex.orig.width;
|
1810
|
+
tempRect.y = -sprite.anchor.y * tex.orig.height;
|
1811
|
+
tempRect.width = tex.orig.width;
|
1812
|
+
tempRect.height = tex.orig.height;
|
1813
|
+
return this.mapQuad(tempRect, quad);
|
1814
|
+
};
|
1815
|
+
Projection2d.prototype.mapQuad = function (rect, p) {
|
1816
|
+
tt[0].set(rect.x, rect.y);
|
1817
|
+
tt[1].set(rect.x + rect.width, rect.y);
|
1818
|
+
tt[2].set(rect.x + rect.width, rect.y + rect.height);
|
1819
|
+
tt[3].set(rect.x, rect.y + rect.height);
|
1820
|
+
var k1 = 1, k2 = 2, k3 = 3;
|
1821
|
+
var f = pixi_projection.utils.getIntersectionFactor(p[0], p[2], p[1], p[3], t0);
|
1822
|
+
if (f !== 0) {
|
1823
|
+
k1 = 1;
|
1824
|
+
k2 = 3;
|
1825
|
+
k3 = 2;
|
1826
|
+
}
|
1827
|
+
else {
|
1828
|
+
return;
|
1829
|
+
}
|
1830
|
+
var d0 = Math.sqrt((p[0].x - t0.x) * (p[0].x - t0.x) + (p[0].y - t0.y) * (p[0].y - t0.y));
|
1831
|
+
var d1 = Math.sqrt((p[k1].x - t0.x) * (p[k1].x - t0.x) + (p[k1].y - t0.y) * (p[k1].y - t0.y));
|
1832
|
+
var d2 = Math.sqrt((p[k2].x - t0.x) * (p[k2].x - t0.x) + (p[k2].y - t0.y) * (p[k2].y - t0.y));
|
1833
|
+
var d3 = Math.sqrt((p[k3].x - t0.x) * (p[k3].x - t0.x) + (p[k3].y - t0.y) * (p[k3].y - t0.y));
|
1834
|
+
var q0 = (d0 + d3) / d3;
|
1835
|
+
var q1 = (d1 + d2) / d2;
|
1836
|
+
var q2 = (d1 + d2) / d1;
|
1837
|
+
var mat3 = this.matrix.mat3;
|
1838
|
+
mat3[0] = tt[0].x * q0;
|
1839
|
+
mat3[1] = tt[0].y * q0;
|
1840
|
+
mat3[2] = q0;
|
1841
|
+
mat3[3] = tt[k1].x * q1;
|
1842
|
+
mat3[4] = tt[k1].y * q1;
|
1843
|
+
mat3[5] = q1;
|
1844
|
+
mat3[6] = tt[k2].x * q2;
|
1845
|
+
mat3[7] = tt[k2].y * q2;
|
1846
|
+
mat3[8] = q2;
|
1847
|
+
this.matrix.invert();
|
1848
|
+
mat3 = tempMat.mat3;
|
1849
|
+
mat3[0] = p[0].x;
|
1850
|
+
mat3[1] = p[0].y;
|
1851
|
+
mat3[2] = 1;
|
1852
|
+
mat3[3] = p[k1].x;
|
1853
|
+
mat3[4] = p[k1].y;
|
1854
|
+
mat3[5] = 1;
|
1855
|
+
mat3[6] = p[k2].x;
|
1856
|
+
mat3[7] = p[k2].y;
|
1857
|
+
mat3[8] = 1;
|
1858
|
+
this.matrix.setToMult(tempMat, this.matrix);
|
1859
|
+
this._projID++;
|
1860
|
+
};
|
1861
|
+
Projection2d.prototype.updateLocalTransform = function (lt) {
|
1862
|
+
if (this._projID !== 0) {
|
1863
|
+
if (this.reverseLocalOrder) {
|
1864
|
+
this.local.setToMultLegacy2(this.matrix, lt);
|
1865
|
+
}
|
1866
|
+
else {
|
1867
|
+
this.local.setToMultLegacy(lt, this.matrix);
|
1868
|
+
}
|
1869
|
+
}
|
1870
|
+
else {
|
1871
|
+
this.local.copyFrom(lt);
|
1872
|
+
}
|
1873
|
+
};
|
1874
|
+
Projection2d.prototype.clear = function () {
|
1875
|
+
_super.prototype.clear.call(this);
|
1876
|
+
this.matrix.identity();
|
1877
|
+
this.pivot.set(0, 0);
|
1878
|
+
};
|
1879
|
+
return Projection2d;
|
1880
|
+
}(pixi_projection.LinearProjection));
|
1881
|
+
pixi_projection.Projection2d = Projection2d;
|
1882
|
+
})(pixi_projection || (pixi_projection = {}));
|
1883
|
+
var pixi_projection;
|
1884
|
+
(function (pixi_projection) {
|
1885
|
+
var Mesh2d = (function (_super) {
|
1886
|
+
__extends(Mesh2d, _super);
|
1887
|
+
function Mesh2d(texture, vertices, uvs, indices, drawMode) {
|
1888
|
+
var _this = _super.call(this, texture, vertices, uvs, indices, drawMode) || this;
|
1889
|
+
_this.proj = new pixi_projection.Projection2d(_this.transform);
|
1890
|
+
_this.pluginName = 'mesh2d';
|
1891
|
+
return _this;
|
1892
|
+
}
|
1893
|
+
Mesh2d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
1894
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
1895
|
+
return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step);
|
1896
|
+
};
|
1897
|
+
Object.defineProperty(Mesh2d.prototype, "worldTransform", {
|
1898
|
+
get: function () {
|
1899
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
1900
|
+
},
|
1901
|
+
enumerable: true,
|
1902
|
+
configurable: true
|
1903
|
+
});
|
1904
|
+
return Mesh2d;
|
1905
|
+
}(PIXI.mesh.Mesh));
|
1906
|
+
pixi_projection.Mesh2d = Mesh2d;
|
1907
|
+
})(pixi_projection || (pixi_projection = {}));
|
1908
|
+
var pixi_projection;
|
1909
|
+
(function (pixi_projection) {
|
1910
|
+
var shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n";
|
1911
|
+
var shaderFrag = "\nvarying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}";
|
1912
|
+
var Mesh2dRenderer = (function (_super) {
|
1913
|
+
__extends(Mesh2dRenderer, _super);
|
1914
|
+
function Mesh2dRenderer() {
|
1915
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
1916
|
+
}
|
1917
|
+
Mesh2dRenderer.prototype.onContextChange = function () {
|
1918
|
+
var gl = this.renderer.gl;
|
1919
|
+
this.shader = new PIXI.Shader(gl, shaderVert, shaderFrag);
|
1920
|
+
};
|
1921
|
+
return Mesh2dRenderer;
|
1922
|
+
}(PIXI.mesh.MeshRenderer));
|
1923
|
+
pixi_projection.Mesh2dRenderer = Mesh2dRenderer;
|
1924
|
+
PIXI.WebGLRenderer.registerPlugin('mesh2d', Mesh2dRenderer);
|
1925
|
+
})(pixi_projection || (pixi_projection = {}));
|
1926
|
+
var pixi_projection;
|
1927
|
+
(function (pixi_projection) {
|
1928
|
+
var Sprite2d = (function (_super) {
|
1929
|
+
__extends(Sprite2d, _super);
|
1930
|
+
function Sprite2d(texture) {
|
1931
|
+
var _this = _super.call(this, texture) || this;
|
1932
|
+
_this.proj = new pixi_projection.Projection2d(_this.transform);
|
1933
|
+
_this.pluginName = 'sprite2d';
|
1934
|
+
_this.vertexData = new Float32Array(12);
|
1935
|
+
return _this;
|
1936
|
+
}
|
1937
|
+
Sprite2d.prototype._calculateBounds = function () {
|
1938
|
+
this.calculateTrimmedVertices();
|
1939
|
+
this._bounds.addQuad(this.vertexTrimmedData);
|
1940
|
+
};
|
1941
|
+
Sprite2d.prototype.calculateVertices = function () {
|
1942
|
+
if (this.proj._affine) {
|
1943
|
+
if (this.vertexData.length != 8) {
|
1944
|
+
this.vertexData = new Float32Array(8);
|
1945
|
+
}
|
1946
|
+
_super.prototype.calculateVertices.call(this);
|
1947
|
+
return;
|
1948
|
+
}
|
1949
|
+
if (this.vertexData.length != 12) {
|
1950
|
+
this.vertexData = new Float32Array(12);
|
1951
|
+
}
|
1952
|
+
var wid = this.transform._worldID;
|
1953
|
+
var tuid = this._texture._updateID;
|
1954
|
+
if (this._transformID === wid && this._textureID === tuid) {
|
1955
|
+
return;
|
1956
|
+
}
|
1957
|
+
this._transformID = wid;
|
1958
|
+
this._textureID = tuid;
|
1959
|
+
var texture = this._texture;
|
1960
|
+
var wt = this.proj.world.mat3;
|
1961
|
+
var vertexData = this.vertexData;
|
1962
|
+
var trim = texture.trim;
|
1963
|
+
var orig = texture.orig;
|
1964
|
+
var anchor = this._anchor;
|
1965
|
+
var w0 = 0;
|
1966
|
+
var w1 = 0;
|
1967
|
+
var h0 = 0;
|
1968
|
+
var h1 = 0;
|
1969
|
+
if (trim) {
|
1970
|
+
w1 = trim.x - (anchor._x * orig.width);
|
1971
|
+
w0 = w1 + trim.width;
|
1972
|
+
h1 = trim.y - (anchor._y * orig.height);
|
1973
|
+
h0 = h1 + trim.height;
|
1974
|
+
}
|
1975
|
+
else {
|
1976
|
+
w1 = -anchor._x * orig.width;
|
1977
|
+
w0 = w1 + orig.width;
|
1978
|
+
h1 = -anchor._y * orig.height;
|
1979
|
+
h0 = h1 + orig.height;
|
1980
|
+
}
|
1981
|
+
vertexData[0] = (wt[0] * w1) + (wt[3] * h1) + wt[6];
|
1982
|
+
vertexData[1] = (wt[1] * w1) + (wt[4] * h1) + wt[7];
|
1983
|
+
vertexData[2] = (wt[2] * w1) + (wt[5] * h1) + wt[8];
|
1984
|
+
vertexData[3] = (wt[0] * w0) + (wt[3] * h1) + wt[6];
|
1985
|
+
vertexData[4] = (wt[1] * w0) + (wt[4] * h1) + wt[7];
|
1986
|
+
vertexData[5] = (wt[2] * w0) + (wt[5] * h1) + wt[8];
|
1987
|
+
vertexData[6] = (wt[0] * w0) + (wt[3] * h0) + wt[6];
|
1988
|
+
vertexData[7] = (wt[1] * w0) + (wt[4] * h0) + wt[7];
|
1989
|
+
vertexData[8] = (wt[2] * w0) + (wt[5] * h0) + wt[8];
|
1990
|
+
vertexData[9] = (wt[0] * w1) + (wt[3] * h0) + wt[6];
|
1991
|
+
vertexData[10] = (wt[1] * w1) + (wt[4] * h0) + wt[7];
|
1992
|
+
vertexData[11] = (wt[2] * w1) + (wt[5] * h0) + wt[8];
|
1993
|
+
};
|
1994
|
+
Sprite2d.prototype.calculateTrimmedVertices = function () {
|
1995
|
+
if (this.proj._affine) {
|
1996
|
+
_super.prototype.calculateTrimmedVertices.call(this);
|
1997
|
+
return;
|
1998
|
+
}
|
1999
|
+
var wid = this.transform._worldID;
|
2000
|
+
var tuid = this._texture._updateID;
|
2001
|
+
if (!this.vertexTrimmedData) {
|
2002
|
+
this.vertexTrimmedData = new Float32Array(8);
|
2003
|
+
}
|
2004
|
+
else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) {
|
2005
|
+
return;
|
2006
|
+
}
|
2007
|
+
this._transformTrimmedID = wid;
|
2008
|
+
this._textureTrimmedID = tuid;
|
2009
|
+
var texture = this._texture;
|
2010
|
+
var vertexData = this.vertexTrimmedData;
|
2011
|
+
var orig = texture.orig;
|
2012
|
+
var anchor = this._anchor;
|
2013
|
+
var wt = this.proj.world.mat3;
|
2014
|
+
var w1 = -anchor._x * orig.width;
|
2015
|
+
var w0 = w1 + orig.width;
|
2016
|
+
var h1 = -anchor._y * orig.height;
|
2017
|
+
var h0 = h1 + orig.height;
|
2018
|
+
var z = 1.0 / (wt[2] * w1 + wt[5] * h1 + wt[8]);
|
2019
|
+
vertexData[0] = z * ((wt[0] * w1) + (wt[3] * h1) + wt[6]);
|
2020
|
+
vertexData[1] = z * ((wt[1] * w1) + (wt[4] * h1) + wt[7]);
|
2021
|
+
z = 1.0 / (wt[2] * w0 + wt[5] * h1 + wt[8]);
|
2022
|
+
vertexData[2] = z * ((wt[0] * w0) + (wt[3] * h1) + wt[6]);
|
2023
|
+
vertexData[3] = z * ((wt[1] * w0) + (wt[4] * h1) + wt[7]);
|
2024
|
+
z = 1.0 / (wt[2] * w0 + wt[5] * h0 + wt[8]);
|
2025
|
+
vertexData[4] = z * ((wt[0] * w0) + (wt[3] * h0) + wt[6]);
|
2026
|
+
vertexData[5] = z * ((wt[1] * w0) + (wt[4] * h0) + wt[7]);
|
2027
|
+
z = 1.0 / (wt[2] * w1 + wt[5] * h0 + wt[8]);
|
2028
|
+
vertexData[6] = z * ((wt[0] * w1) + (wt[3] * h0) + wt[6]);
|
2029
|
+
vertexData[7] = z * ((wt[1] * w1) + (wt[4] * h0) + wt[7]);
|
2030
|
+
};
|
2031
|
+
Sprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
2032
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
2033
|
+
return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step);
|
2034
|
+
};
|
2035
|
+
Object.defineProperty(Sprite2d.prototype, "worldTransform", {
|
2036
|
+
get: function () {
|
2037
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
2038
|
+
},
|
2039
|
+
enumerable: true,
|
2040
|
+
configurable: true
|
2041
|
+
});
|
2042
|
+
return Sprite2d;
|
2043
|
+
}(PIXI.Sprite));
|
2044
|
+
pixi_projection.Sprite2d = Sprite2d;
|
2045
|
+
})(pixi_projection || (pixi_projection = {}));
|
2046
|
+
var pixi_projection;
|
2047
|
+
(function (pixi_projection) {
|
2048
|
+
var MultiTextureSpriteRenderer = pixi_projection.webgl.MultiTextureSpriteRenderer;
|
2049
|
+
var Sprite2dRenderer = (function (_super) {
|
2050
|
+
__extends(Sprite2dRenderer, _super);
|
2051
|
+
function Sprite2dRenderer() {
|
2052
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
2053
|
+
_this.shaderVert = "precision highp float;\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * aVertexPosition;\n gl_Position.z = 0.0;\n \n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n";
|
2054
|
+
_this.shaderFrag = "\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\nvec4 color;\nvec2 textureCoord = vTextureCoord;\nfloat textureId = floor(vTextureId+0.5);\n%forloop%\ngl_FragColor = color * vColor;\n}";
|
2055
|
+
return _this;
|
2056
|
+
}
|
2057
|
+
Sprite2dRenderer.prototype.createVao = function (vertexBuffer) {
|
2058
|
+
var attrs = this.shader.attributes;
|
2059
|
+
this.vertSize = 6;
|
2060
|
+
this.vertByteSize = this.vertSize * 4;
|
2061
|
+
var gl = this.renderer.gl;
|
2062
|
+
var vao = this.renderer.createVao()
|
2063
|
+
.addIndex(this.indexBuffer)
|
2064
|
+
.addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0)
|
2065
|
+
.addAttribute(vertexBuffer, attrs.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 3 * 4)
|
2066
|
+
.addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 4 * 4);
|
2067
|
+
if (attrs.aTextureId) {
|
2068
|
+
vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 5 * 4);
|
2069
|
+
}
|
2070
|
+
return vao;
|
2071
|
+
};
|
2072
|
+
Sprite2dRenderer.prototype.fillVertices = function (float32View, uint32View, index, sprite, argb, textureId) {
|
2073
|
+
var vertexData = sprite.vertexData;
|
2074
|
+
var uvs = sprite._texture._uvs.uvsUint32;
|
2075
|
+
if (vertexData.length === 8) {
|
2076
|
+
if (this.renderer.roundPixels) {
|
2077
|
+
var resolution = this.renderer.resolution;
|
2078
|
+
float32View[index] = ((vertexData[0] * resolution) | 0) / resolution;
|
2079
|
+
float32View[index + 1] = ((vertexData[1] * resolution) | 0) / resolution;
|
2080
|
+
float32View[index + 2] = 1.0;
|
2081
|
+
float32View[index + 6] = ((vertexData[2] * resolution) | 0) / resolution;
|
2082
|
+
float32View[index + 7] = ((vertexData[3] * resolution) | 0) / resolution;
|
2083
|
+
float32View[index + 8] = 1.0;
|
2084
|
+
float32View[index + 12] = ((vertexData[4] * resolution) | 0) / resolution;
|
2085
|
+
float32View[index + 13] = ((vertexData[5] * resolution) | 0) / resolution;
|
2086
|
+
float32View[index + 14] = 1.0;
|
2087
|
+
float32View[index + 18] = ((vertexData[6] * resolution) | 0) / resolution;
|
2088
|
+
float32View[index + 19] = ((vertexData[7] * resolution) | 0) / resolution;
|
2089
|
+
float32View[index + 20] = 1.0;
|
2090
|
+
}
|
2091
|
+
else {
|
2092
|
+
float32View[index] = vertexData[0];
|
2093
|
+
float32View[index + 1] = vertexData[1];
|
2094
|
+
float32View[index + 2] = 1.0;
|
2095
|
+
float32View[index + 6] = vertexData[2];
|
2096
|
+
float32View[index + 7] = vertexData[3];
|
2097
|
+
float32View[index + 8] = 1.0;
|
2098
|
+
float32View[index + 12] = vertexData[4];
|
2099
|
+
float32View[index + 13] = vertexData[5];
|
2100
|
+
float32View[index + 14] = 1.0;
|
2101
|
+
float32View[index + 18] = vertexData[6];
|
2102
|
+
float32View[index + 19] = vertexData[7];
|
2103
|
+
float32View[index + 20] = 1.0;
|
2104
|
+
}
|
2105
|
+
}
|
2106
|
+
else {
|
2107
|
+
float32View[index] = vertexData[0];
|
2108
|
+
float32View[index + 1] = vertexData[1];
|
2109
|
+
float32View[index + 2] = vertexData[2];
|
2110
|
+
float32View[index + 6] = vertexData[3];
|
2111
|
+
float32View[index + 7] = vertexData[4];
|
2112
|
+
float32View[index + 8] = vertexData[5];
|
2113
|
+
float32View[index + 12] = vertexData[6];
|
2114
|
+
float32View[index + 13] = vertexData[7];
|
2115
|
+
float32View[index + 14] = vertexData[8];
|
2116
|
+
float32View[index + 18] = vertexData[9];
|
2117
|
+
float32View[index + 19] = vertexData[10];
|
2118
|
+
float32View[index + 20] = vertexData[11];
|
2119
|
+
}
|
2120
|
+
uint32View[index + 3] = uvs[0];
|
2121
|
+
uint32View[index + 9] = uvs[1];
|
2122
|
+
uint32View[index + 15] = uvs[2];
|
2123
|
+
uint32View[index + 21] = uvs[3];
|
2124
|
+
uint32View[index + 4] = uint32View[index + 10] = uint32View[index + 16] = uint32View[index + 22] = argb;
|
2125
|
+
float32View[index + 5] = float32View[index + 11] = float32View[index + 17] = float32View[index + 23] = textureId;
|
2126
|
+
};
|
2127
|
+
return Sprite2dRenderer;
|
2128
|
+
}(MultiTextureSpriteRenderer));
|
2129
|
+
PIXI.WebGLRenderer.registerPlugin('sprite2d', Sprite2dRenderer);
|
2130
|
+
})(pixi_projection || (pixi_projection = {}));
|
2131
|
+
var pixi_projection;
|
2132
|
+
(function (pixi_projection) {
|
2133
|
+
var Text2d = (function (_super) {
|
2134
|
+
__extends(Text2d, _super);
|
2135
|
+
function Text2d(text, style, canvas) {
|
2136
|
+
var _this = _super.call(this, text, style, canvas) || this;
|
2137
|
+
_this.proj = new pixi_projection.Projection2d(_this.transform);
|
2138
|
+
_this.pluginName = 'sprite2d';
|
2139
|
+
_this.vertexData = new Float32Array(12);
|
2140
|
+
return _this;
|
2141
|
+
}
|
2142
|
+
Object.defineProperty(Text2d.prototype, "worldTransform", {
|
2143
|
+
get: function () {
|
2144
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
2145
|
+
},
|
2146
|
+
enumerable: true,
|
2147
|
+
configurable: true
|
2148
|
+
});
|
2149
|
+
return Text2d;
|
2150
|
+
}(PIXI.Text));
|
2151
|
+
pixi_projection.Text2d = Text2d;
|
2152
|
+
Text2d.prototype.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices;
|
2153
|
+
Text2d.prototype.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices;
|
2154
|
+
Text2d.prototype._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds;
|
2155
|
+
})(pixi_projection || (pixi_projection = {}));
|
2156
|
+
var pixi_projection;
|
2157
|
+
(function (pixi_projection) {
|
2158
|
+
function convertTo2d() {
|
2159
|
+
if (this.proj)
|
2160
|
+
return;
|
2161
|
+
this.proj = new pixi_projection.Projection2d(this.transform);
|
2162
|
+
this.toLocal = pixi_projection.Container2d.prototype.toLocal;
|
2163
|
+
Object.defineProperty(this, "worldTransform", {
|
2164
|
+
get: pixi_projection.container2dWorldTransform,
|
2165
|
+
enumerable: true,
|
2166
|
+
configurable: true
|
2167
|
+
});
|
2168
|
+
}
|
2169
|
+
PIXI.Container.prototype.convertTo2d = convertTo2d;
|
2170
|
+
PIXI.Sprite.prototype.convertTo2d = function () {
|
2171
|
+
if (this.proj)
|
2172
|
+
return;
|
2173
|
+
this.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices;
|
2174
|
+
this.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices;
|
2175
|
+
this._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds;
|
2176
|
+
this.pluginName = 'sprite2d';
|
2177
|
+
this.vertexData = new Float32Array(12);
|
2178
|
+
convertTo2d.call(this);
|
2179
|
+
};
|
2180
|
+
PIXI.mesh.Mesh.prototype.convertTo2d = function () {
|
2181
|
+
if (this.proj)
|
2182
|
+
return;
|
2183
|
+
this.pluginName = 'mesh2d';
|
2184
|
+
convertTo2d.call(this);
|
2185
|
+
};
|
2186
|
+
PIXI.Container.prototype.convertSubtreeTo2d = function () {
|
2187
|
+
this.convertTo2d();
|
2188
|
+
for (var i = 0; i < this.children.length; i++) {
|
2189
|
+
this.children[i].convertSubtreeTo2d();
|
2190
|
+
}
|
2191
|
+
};
|
2192
|
+
})(pixi_projection || (pixi_projection = {}));
|
2193
|
+
var pixi_projection;
|
2194
|
+
(function (pixi_projection) {
|
2195
|
+
var tempTransform = new PIXI.TransformStatic();
|
2196
|
+
var TilingSprite2d = (function (_super) {
|
2197
|
+
__extends(TilingSprite2d, _super);
|
2198
|
+
function TilingSprite2d(texture, width, height) {
|
2199
|
+
var _this = _super.call(this, texture, width, height) || this;
|
2200
|
+
_this.tileProj = new pixi_projection.Projection2d(_this.tileTransform);
|
2201
|
+
_this.tileProj.reverseLocalOrder = true;
|
2202
|
+
_this.proj = new pixi_projection.Projection2d(_this.transform);
|
2203
|
+
_this.pluginName = 'tilingSprite2d';
|
2204
|
+
_this.uvRespectAnchor = true;
|
2205
|
+
return _this;
|
2206
|
+
}
|
2207
|
+
Object.defineProperty(TilingSprite2d.prototype, "worldTransform", {
|
2208
|
+
get: function () {
|
2209
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
2210
|
+
},
|
2211
|
+
enumerable: true,
|
2212
|
+
configurable: true
|
2213
|
+
});
|
2214
|
+
TilingSprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
2215
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
2216
|
+
return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step);
|
2217
|
+
};
|
2218
|
+
TilingSprite2d.prototype._renderWebGL = function (renderer) {
|
2219
|
+
var texture = this._texture;
|
2220
|
+
if (!texture || !texture.valid) {
|
2221
|
+
return;
|
2222
|
+
}
|
2223
|
+
this.tileTransform.updateTransform(tempTransform);
|
2224
|
+
this.uvTransform.update();
|
2225
|
+
renderer.setObjectRenderer(renderer.plugins[this.pluginName]);
|
2226
|
+
renderer.plugins[this.pluginName].render(this);
|
2227
|
+
};
|
2228
|
+
return TilingSprite2d;
|
2229
|
+
}(PIXI.extras.TilingSprite));
|
2230
|
+
pixi_projection.TilingSprite2d = TilingSprite2d;
|
2231
|
+
})(pixi_projection || (pixi_projection = {}));
|
2232
|
+
var pixi_projection;
|
2233
|
+
(function (pixi_projection) {
|
2234
|
+
var shaderVert = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec3 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n\n vTextureCoord = uTransform * vec3(aTextureCoord, 1.0);\n}\n";
|
2235
|
+
var shaderFrag = "\nvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord.xy / vTextureCoord.z - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n";
|
2236
|
+
var shaderSimpleFrag = "\n\tvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord.xy / vTextureCoord.z);\n gl_FragColor = sample * uColor;\n}\n";
|
2237
|
+
var tempMat = new pixi_projection.Matrix2d();
|
2238
|
+
var WRAP_MODES = PIXI.WRAP_MODES;
|
2239
|
+
var utils = PIXI.utils;
|
2240
|
+
var TilingSprite2dRenderer = (function (_super) {
|
2241
|
+
__extends(TilingSprite2dRenderer, _super);
|
2242
|
+
function TilingSprite2dRenderer() {
|
2243
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
2244
|
+
}
|
2245
|
+
TilingSprite2dRenderer.prototype.onContextChange = function () {
|
2246
|
+
var gl = this.renderer.gl;
|
2247
|
+
this.shader = new PIXI.Shader(gl, shaderVert, shaderFrag);
|
2248
|
+
this.simpleShader = new PIXI.Shader(gl, shaderVert, shaderSimpleFrag);
|
2249
|
+
this.renderer.bindVao(null);
|
2250
|
+
this.quad = new PIXI.Quad(gl, this.renderer.state.attribState);
|
2251
|
+
this.quad.initVao(this.shader);
|
2252
|
+
};
|
2253
|
+
TilingSprite2dRenderer.prototype.render = function (ts) {
|
2254
|
+
var renderer = this.renderer;
|
2255
|
+
var quad = this.quad;
|
2256
|
+
renderer.bindVao(quad.vao);
|
2257
|
+
var vertices = quad.vertices;
|
2258
|
+
vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x;
|
2259
|
+
vertices[1] = vertices[3] = ts._height * -ts.anchor.y;
|
2260
|
+
vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x);
|
2261
|
+
vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y);
|
2262
|
+
if (ts.uvRespectAnchor) {
|
2263
|
+
vertices = quad.uvs;
|
2264
|
+
vertices[0] = vertices[6] = -ts.anchor.x;
|
2265
|
+
vertices[1] = vertices[3] = -ts.anchor.y;
|
2266
|
+
vertices[2] = vertices[4] = 1.0 - ts.anchor.x;
|
2267
|
+
vertices[5] = vertices[7] = 1.0 - ts.anchor.y;
|
2268
|
+
}
|
2269
|
+
quad.upload();
|
2270
|
+
var tex = ts._texture;
|
2271
|
+
var baseTex = tex.baseTexture;
|
2272
|
+
var lt = ts.tileProj.world;
|
2273
|
+
var uv = ts.uvTransform;
|
2274
|
+
var isSimple = baseTex.isPowerOfTwo
|
2275
|
+
&& tex.frame.width === baseTex.width && tex.frame.height === baseTex.height;
|
2276
|
+
if (isSimple) {
|
2277
|
+
if (!baseTex._glTextures[renderer.CONTEXT_UID]) {
|
2278
|
+
if (baseTex.wrapMode === WRAP_MODES.CLAMP) {
|
2279
|
+
baseTex.wrapMode = WRAP_MODES.REPEAT;
|
2280
|
+
}
|
2281
|
+
}
|
2282
|
+
else {
|
2283
|
+
isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP;
|
2284
|
+
}
|
2285
|
+
}
|
2286
|
+
var shader = isSimple ? this.simpleShader : this.shader;
|
2287
|
+
renderer.bindShader(shader);
|
2288
|
+
tempMat.identity();
|
2289
|
+
tempMat.scale(tex.width, tex.height);
|
2290
|
+
tempMat.prepend(lt);
|
2291
|
+
tempMat.scale(1.0 / ts._width, 1.0 / ts._height);
|
2292
|
+
tempMat.invert();
|
2293
|
+
if (isSimple) {
|
2294
|
+
tempMat.prepend(uv.mapCoord);
|
2295
|
+
}
|
2296
|
+
else {
|
2297
|
+
shader.uniforms.uMapCoord = uv.mapCoord.toArray(true);
|
2298
|
+
shader.uniforms.uClampFrame = uv.uClampFrame;
|
2299
|
+
shader.uniforms.uClampOffset = uv.uClampOffset;
|
2300
|
+
}
|
2301
|
+
shader.uniforms.uTransform = tempMat.toArray(true);
|
2302
|
+
shader.uniforms.uColor = utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultipliedAlpha);
|
2303
|
+
shader.uniforms.translationMatrix = ts.proj.world.toArray(true);
|
2304
|
+
shader.uniforms.uSampler = renderer.bindTexture(tex);
|
2305
|
+
renderer.setBlendMode(utils.correctBlendMode(ts.blendMode, baseTex.premultipliedAlpha));
|
2306
|
+
quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0);
|
2307
|
+
};
|
2308
|
+
return TilingSprite2dRenderer;
|
2309
|
+
}(PIXI.extras.TilingSpriteRenderer));
|
2310
|
+
pixi_projection.TilingSprite2dRenderer = TilingSprite2dRenderer;
|
2311
|
+
PIXI.WebGLRenderer.registerPlugin('tilingSprite2d', TilingSprite2dRenderer);
|
2312
|
+
})(pixi_projection || (pixi_projection = {}));
|
2313
|
+
var pixi_projection;
|
2314
|
+
(function (pixi_projection) {
|
2315
|
+
var ProjectionsManager = (function () {
|
2316
|
+
function ProjectionsManager(renderer) {
|
2317
|
+
var _this = this;
|
2318
|
+
this.onContextChange = function (gl) {
|
2319
|
+
_this.gl = gl;
|
2320
|
+
_this.renderer.maskManager.pushSpriteMask = pushSpriteMask;
|
2321
|
+
};
|
2322
|
+
this.renderer = renderer;
|
2323
|
+
renderer.on('context', this.onContextChange);
|
2324
|
+
}
|
2325
|
+
ProjectionsManager.prototype.destroy = function () {
|
2326
|
+
this.renderer.off('context', this.onContextChange);
|
2327
|
+
};
|
2328
|
+
return ProjectionsManager;
|
2329
|
+
}());
|
2330
|
+
pixi_projection.ProjectionsManager = ProjectionsManager;
|
2331
|
+
function pushSpriteMask(target, maskData) {
|
2332
|
+
var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex];
|
2333
|
+
if (!alphaMaskFilter) {
|
2334
|
+
alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new pixi_projection.SpriteMaskFilter2d(maskData)];
|
2335
|
+
}
|
2336
|
+
alphaMaskFilter[0].resolution = this.renderer.resolution;
|
2337
|
+
alphaMaskFilter[0].maskSprite = maskData;
|
2338
|
+
target.filterArea = maskData.getBounds(true);
|
2339
|
+
this.renderer.filterManager.pushFilter(target, alphaMaskFilter);
|
2340
|
+
this.alphaMaskIndex++;
|
2341
|
+
}
|
2342
|
+
PIXI.WebGLRenderer.registerPlugin('projections', ProjectionsManager);
|
2343
|
+
})(pixi_projection || (pixi_projection = {}));
|
2344
|
+
var pixi_projection;
|
2345
|
+
(function (pixi_projection) {
|
2346
|
+
var spriteMaskVert = "\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n\tvTextureCoord = aTextureCoord;\n\tvMaskCoord = otherMatrix * vec3( aTextureCoord, 1.0);\n}\n";
|
2347
|
+
var spriteMaskFrag = "\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n vec2 uv = vMaskCoord.xy / vMaskCoord.z;\n \n vec2 text = abs( uv - 0.5 );\n text = step(0.5, text);\n\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, uv);\n\n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n";
|
2348
|
+
var tempMat = new pixi_projection.Matrix2d();
|
2349
|
+
var SpriteMaskFilter2d = (function (_super) {
|
2350
|
+
__extends(SpriteMaskFilter2d, _super);
|
2351
|
+
function SpriteMaskFilter2d(sprite) {
|
2352
|
+
var _this = _super.call(this, spriteMaskVert, spriteMaskFrag) || this;
|
2353
|
+
_this.maskMatrix = new pixi_projection.Matrix2d();
|
2354
|
+
sprite.renderable = false;
|
2355
|
+
_this.maskSprite = sprite;
|
2356
|
+
return _this;
|
2357
|
+
}
|
2358
|
+
SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear, currentState) {
|
2359
|
+
var maskSprite = this.maskSprite;
|
2360
|
+
this.uniforms.mask = maskSprite.texture;
|
2361
|
+
this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(currentState, this.maskMatrix, maskSprite);
|
2362
|
+
this.uniforms.alpha = maskSprite.worldAlpha;
|
2363
|
+
filterManager.applyFilter(this, input, output);
|
2364
|
+
};
|
2365
|
+
SpriteMaskFilter2d.calculateSpriteMatrix = function (currentState, mappedMatrix, sprite) {
|
2366
|
+
var proj = sprite.proj;
|
2367
|
+
var filterArea = currentState.sourceFrame;
|
2368
|
+
var textureSize = currentState.renderTarget.size;
|
2369
|
+
var worldTransform = proj && !proj._affine ? proj.world.copyTo(tempMat) : tempMat.copyFrom(sprite.transform.worldTransform);
|
2370
|
+
var texture = sprite.texture.orig;
|
2371
|
+
mappedMatrix.set(textureSize.width, 0, 0, textureSize.height, filterArea.x, filterArea.y);
|
2372
|
+
worldTransform.invert();
|
2373
|
+
mappedMatrix.setToMult(worldTransform, mappedMatrix);
|
2374
|
+
mappedMatrix.scaleAndTranslate(1.0 / texture.width, 1.0 / texture.height, sprite.anchor.x, sprite.anchor.y);
|
2375
|
+
return mappedMatrix;
|
2376
|
+
};
|
2377
|
+
return SpriteMaskFilter2d;
|
2378
|
+
}(PIXI.Filter));
|
2379
|
+
pixi_projection.SpriteMaskFilter2d = SpriteMaskFilter2d;
|
2380
|
+
})(pixi_projection || (pixi_projection = {}));
|
2381
|
+
var pixi_projection;
|
2382
|
+
(function (pixi_projection) {
|
2383
|
+
function container3dWorldTransform() {
|
2384
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
2385
|
+
}
|
2386
|
+
pixi_projection.container3dWorldTransform = container3dWorldTransform;
|
2387
|
+
var Container3d = (function (_super) {
|
2388
|
+
__extends(Container3d, _super);
|
2389
|
+
function Container3d() {
|
2390
|
+
var _this = _super.call(this) || this;
|
2391
|
+
_this.proj = new pixi_projection.Projection3d(_this.transform);
|
2392
|
+
return _this;
|
2393
|
+
}
|
2394
|
+
Container3d.prototype.isFrontFace = function (forceUpdate) {
|
2395
|
+
if (forceUpdate === void 0) { forceUpdate = false; }
|
2396
|
+
if (forceUpdate) {
|
2397
|
+
this._recursivePostUpdateTransform();
|
2398
|
+
this.displayObjectUpdateTransform();
|
2399
|
+
}
|
2400
|
+
var mat = this.proj.world.mat4;
|
2401
|
+
var dx1 = mat[0] * mat[15] - mat[3] * mat[12];
|
2402
|
+
var dy1 = mat[1] * mat[15] - mat[3] * mat[13];
|
2403
|
+
var dx2 = mat[4] * mat[15] - mat[7] * mat[12];
|
2404
|
+
var dy2 = mat[5] * mat[15] - mat[7] * mat[13];
|
2405
|
+
return dx1 * dy2 - dx2 * dy1 > 0;
|
2406
|
+
};
|
2407
|
+
Container3d.prototype.getDepth = function (forceUpdate) {
|
2408
|
+
if (forceUpdate === void 0) { forceUpdate = false; }
|
2409
|
+
if (forceUpdate) {
|
2410
|
+
this._recursivePostUpdateTransform();
|
2411
|
+
this.displayObjectUpdateTransform();
|
2412
|
+
}
|
2413
|
+
var mat4 = this.proj.world.mat4;
|
2414
|
+
return mat4[14] / mat4[15];
|
2415
|
+
};
|
2416
|
+
Container3d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
2417
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
2418
|
+
if (from) {
|
2419
|
+
position = from.toGlobal(position, point, skipUpdate);
|
2420
|
+
}
|
2421
|
+
if (!skipUpdate) {
|
2422
|
+
this._recursivePostUpdateTransform();
|
2423
|
+
}
|
2424
|
+
if (step === pixi_projection.TRANSFORM_STEP.ALL) {
|
2425
|
+
if (!skipUpdate) {
|
2426
|
+
this.displayObjectUpdateTransform();
|
2427
|
+
}
|
2428
|
+
if (this.proj.affine) {
|
2429
|
+
return this.transform.worldTransform.applyInverse(point, point);
|
2430
|
+
}
|
2431
|
+
return this.proj.world.applyInverse(point, point);
|
2432
|
+
}
|
2433
|
+
if (this.parent) {
|
2434
|
+
point = this.parent.worldTransform.applyInverse(position, point);
|
2435
|
+
}
|
2436
|
+
else {
|
2437
|
+
point.copy(position);
|
2438
|
+
}
|
2439
|
+
if (step === pixi_projection.TRANSFORM_STEP.NONE) {
|
2440
|
+
return point;
|
2441
|
+
}
|
2442
|
+
point = this.transform.localTransform.applyInverse(point, point);
|
2443
|
+
if (step === pixi_projection.TRANSFORM_STEP.PROJ && this.proj.cameraMode) {
|
2444
|
+
point = this.proj.cameraMatrix.applyInverse(point, point);
|
2445
|
+
}
|
2446
|
+
return point;
|
2447
|
+
};
|
2448
|
+
Object.defineProperty(Container3d.prototype, "worldTransform", {
|
2449
|
+
get: function () {
|
2450
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
2451
|
+
},
|
2452
|
+
enumerable: true,
|
2453
|
+
configurable: true
|
2454
|
+
});
|
2455
|
+
Object.defineProperty(Container3d.prototype, "position3d", {
|
2456
|
+
get: function () {
|
2457
|
+
return this.proj.position;
|
2458
|
+
},
|
2459
|
+
set: function (value) {
|
2460
|
+
this.proj.position.copy(value);
|
2461
|
+
},
|
2462
|
+
enumerable: true,
|
2463
|
+
configurable: true
|
2464
|
+
});
|
2465
|
+
Object.defineProperty(Container3d.prototype, "scale3d", {
|
2466
|
+
get: function () {
|
2467
|
+
return this.proj.scale;
|
2468
|
+
},
|
2469
|
+
set: function (value) {
|
2470
|
+
this.proj.scale.copy(value);
|
2471
|
+
},
|
2472
|
+
enumerable: true,
|
2473
|
+
configurable: true
|
2474
|
+
});
|
2475
|
+
Object.defineProperty(Container3d.prototype, "euler", {
|
2476
|
+
get: function () {
|
2477
|
+
return this.proj.euler;
|
2478
|
+
},
|
2479
|
+
set: function (value) {
|
2480
|
+
this.proj.euler.copy(value);
|
2481
|
+
},
|
2482
|
+
enumerable: true,
|
2483
|
+
configurable: true
|
2484
|
+
});
|
2485
|
+
Object.defineProperty(Container3d.prototype, "pivot3d", {
|
2486
|
+
get: function () {
|
2487
|
+
return this.proj.pivot;
|
2488
|
+
},
|
2489
|
+
set: function (value) {
|
2490
|
+
this.proj.pivot.copy(value);
|
2491
|
+
},
|
2492
|
+
enumerable: true,
|
2493
|
+
configurable: true
|
2494
|
+
});
|
2495
|
+
return Container3d;
|
2496
|
+
}(PIXI.Container));
|
2497
|
+
pixi_projection.Container3d = Container3d;
|
2498
|
+
pixi_projection.container3dToLocal = Container3d.prototype.toLocal;
|
2499
|
+
pixi_projection.container3dGetDepth = Container3d.prototype.getDepth;
|
2500
|
+
pixi_projection.container3dIsFrontFace = Container3d.prototype.isFrontFace;
|
2501
|
+
})(pixi_projection || (pixi_projection = {}));
|
2502
|
+
var pixi_projection;
|
2503
|
+
(function (pixi_projection) {
|
2504
|
+
var Camera3d = (function (_super) {
|
2505
|
+
__extends(Camera3d, _super);
|
2506
|
+
function Camera3d() {
|
2507
|
+
var _this = _super.call(this) || this;
|
2508
|
+
_this._far = 0;
|
2509
|
+
_this._near = 0;
|
2510
|
+
_this._focus = 0;
|
2511
|
+
_this._orthographic = false;
|
2512
|
+
_this.proj.cameraMode = true;
|
2513
|
+
_this.setPlanes(400, 10, 10000, false);
|
2514
|
+
return _this;
|
2515
|
+
}
|
2516
|
+
Object.defineProperty(Camera3d.prototype, "far", {
|
2517
|
+
get: function () {
|
2518
|
+
return this._far;
|
2519
|
+
},
|
2520
|
+
enumerable: true,
|
2521
|
+
configurable: true
|
2522
|
+
});
|
2523
|
+
Object.defineProperty(Camera3d.prototype, "near", {
|
2524
|
+
get: function () {
|
2525
|
+
return this._near;
|
2526
|
+
},
|
2527
|
+
enumerable: true,
|
2528
|
+
configurable: true
|
2529
|
+
});
|
2530
|
+
Object.defineProperty(Camera3d.prototype, "focus", {
|
2531
|
+
get: function () {
|
2532
|
+
return this._focus;
|
2533
|
+
},
|
2534
|
+
enumerable: true,
|
2535
|
+
configurable: true
|
2536
|
+
});
|
2537
|
+
Object.defineProperty(Camera3d.prototype, "ortographic", {
|
2538
|
+
get: function () {
|
2539
|
+
return this._orthographic;
|
2540
|
+
},
|
2541
|
+
enumerable: true,
|
2542
|
+
configurable: true
|
2543
|
+
});
|
2544
|
+
Camera3d.prototype.setPlanes = function (focus, near, far, orthographic) {
|
2545
|
+
if (near === void 0) { near = 10; }
|
2546
|
+
if (far === void 0) { far = 10000; }
|
2547
|
+
if (orthographic === void 0) { orthographic = false; }
|
2548
|
+
this._focus = focus;
|
2549
|
+
this._near = near;
|
2550
|
+
this._far = far;
|
2551
|
+
this._orthographic = orthographic;
|
2552
|
+
var proj = this.proj;
|
2553
|
+
var mat4 = proj.cameraMatrix.mat4;
|
2554
|
+
proj._projID++;
|
2555
|
+
mat4[10] = 1.0 / (far - near);
|
2556
|
+
mat4[14] = (focus - near) / (far - near);
|
2557
|
+
if (this._orthographic) {
|
2558
|
+
mat4[11] = 0;
|
2559
|
+
}
|
2560
|
+
else {
|
2561
|
+
mat4[11] = 1.0 / focus;
|
2562
|
+
}
|
2563
|
+
};
|
2564
|
+
return Camera3d;
|
2565
|
+
}(pixi_projection.Container3d));
|
2566
|
+
pixi_projection.Camera3d = Camera3d;
|
2567
|
+
})(pixi_projection || (pixi_projection = {}));
|
2568
|
+
var pixi_projection;
|
2569
|
+
(function (pixi_projection) {
|
2570
|
+
var Euler = (function () {
|
2571
|
+
function Euler(x, y, z) {
|
2572
|
+
this._quatUpdateId = -1;
|
2573
|
+
this._quatDirtyId = 0;
|
2574
|
+
this._sign = 1;
|
2575
|
+
this._x = x || 0;
|
2576
|
+
this._y = y || 0;
|
2577
|
+
this._z = z || 0;
|
2578
|
+
this.quaternion = new Float64Array(4);
|
2579
|
+
this.quaternion[3] = 1;
|
2580
|
+
this.update();
|
2581
|
+
}
|
2582
|
+
Object.defineProperty(Euler.prototype, "x", {
|
2583
|
+
get: function () {
|
2584
|
+
return this._x;
|
2585
|
+
},
|
2586
|
+
set: function (value) {
|
2587
|
+
if (this._x !== value) {
|
2588
|
+
this._x = value;
|
2589
|
+
this._quatDirtyId++;
|
2590
|
+
}
|
2591
|
+
},
|
2592
|
+
enumerable: true,
|
2593
|
+
configurable: true
|
2594
|
+
});
|
2595
|
+
Object.defineProperty(Euler.prototype, "y", {
|
2596
|
+
get: function () {
|
2597
|
+
return this._y;
|
2598
|
+
},
|
2599
|
+
set: function (value) {
|
2600
|
+
if (this._y !== value) {
|
2601
|
+
this._y = value;
|
2602
|
+
this._quatDirtyId++;
|
2603
|
+
}
|
2604
|
+
},
|
2605
|
+
enumerable: true,
|
2606
|
+
configurable: true
|
2607
|
+
});
|
2608
|
+
Object.defineProperty(Euler.prototype, "z", {
|
2609
|
+
get: function () {
|
2610
|
+
return this._z;
|
2611
|
+
},
|
2612
|
+
set: function (value) {
|
2613
|
+
if (this._z !== value) {
|
2614
|
+
this._z = value;
|
2615
|
+
this._quatDirtyId++;
|
2616
|
+
}
|
2617
|
+
},
|
2618
|
+
enumerable: true,
|
2619
|
+
configurable: true
|
2620
|
+
});
|
2621
|
+
Object.defineProperty(Euler.prototype, "pitch", {
|
2622
|
+
get: function () {
|
2623
|
+
return this._x;
|
2624
|
+
},
|
2625
|
+
set: function (value) {
|
2626
|
+
if (this._x !== value) {
|
2627
|
+
this._x = value;
|
2628
|
+
this._quatDirtyId++;
|
2629
|
+
}
|
2630
|
+
},
|
2631
|
+
enumerable: true,
|
2632
|
+
configurable: true
|
2633
|
+
});
|
2634
|
+
Object.defineProperty(Euler.prototype, "yaw", {
|
2635
|
+
get: function () {
|
2636
|
+
return this._y;
|
2637
|
+
},
|
2638
|
+
set: function (value) {
|
2639
|
+
if (this._y !== value) {
|
2640
|
+
this._y = value;
|
2641
|
+
this._quatDirtyId++;
|
2642
|
+
}
|
2643
|
+
},
|
2644
|
+
enumerable: true,
|
2645
|
+
configurable: true
|
2646
|
+
});
|
2647
|
+
Object.defineProperty(Euler.prototype, "roll", {
|
2648
|
+
get: function () {
|
2649
|
+
return this._z;
|
2650
|
+
},
|
2651
|
+
set: function (value) {
|
2652
|
+
if (this._z !== value) {
|
2653
|
+
this._z = value;
|
2654
|
+
this._quatDirtyId++;
|
2655
|
+
}
|
2656
|
+
},
|
2657
|
+
enumerable: true,
|
2658
|
+
configurable: true
|
2659
|
+
});
|
2660
|
+
Euler.prototype.set = function (x, y, z) {
|
2661
|
+
var _x = x || 0;
|
2662
|
+
var _y = y || 0;
|
2663
|
+
var _z = z || 0;
|
2664
|
+
if (this._x !== _x || this._y !== _y || this._z !== _z) {
|
2665
|
+
this._x = _x;
|
2666
|
+
this._y = _y;
|
2667
|
+
this._z = _z;
|
2668
|
+
this._quatDirtyId++;
|
2669
|
+
}
|
2670
|
+
};
|
2671
|
+
;
|
2672
|
+
Euler.prototype.copy = function (euler) {
|
2673
|
+
var _x = euler.x;
|
2674
|
+
var _y = euler.y;
|
2675
|
+
var _z = euler.z;
|
2676
|
+
if (this._x !== _x || this._y !== _y || this._z !== _z) {
|
2677
|
+
this._x = _x;
|
2678
|
+
this._y = _y;
|
2679
|
+
this._z = _z;
|
2680
|
+
this._quatDirtyId++;
|
2681
|
+
}
|
2682
|
+
};
|
2683
|
+
Euler.prototype.clone = function () {
|
2684
|
+
return new Euler(this._x, this._y, this._z);
|
2685
|
+
};
|
2686
|
+
Euler.prototype.update = function () {
|
2687
|
+
if (this._quatUpdateId === this._quatDirtyId) {
|
2688
|
+
return false;
|
2689
|
+
}
|
2690
|
+
this._quatUpdateId = this._quatDirtyId;
|
2691
|
+
var c1 = Math.cos(this._x / 2);
|
2692
|
+
var c2 = Math.cos(this._y / 2);
|
2693
|
+
var c3 = Math.cos(this._z / 2);
|
2694
|
+
var s = this._sign;
|
2695
|
+
var s1 = s * Math.sin(this._x / 2);
|
2696
|
+
var s2 = s * Math.sin(this._y / 2);
|
2697
|
+
var s3 = s * Math.sin(this._z / 2);
|
2698
|
+
var q = this.quaternion;
|
2699
|
+
q[0] = s1 * c2 * c3 + c1 * s2 * s3;
|
2700
|
+
q[1] = c1 * s2 * c3 - s1 * c2 * s3;
|
2701
|
+
q[2] = c1 * c2 * s3 + s1 * s2 * c3;
|
2702
|
+
q[3] = c1 * c2 * c3 - s1 * s2 * s3;
|
2703
|
+
return true;
|
2704
|
+
};
|
2705
|
+
return Euler;
|
2706
|
+
}());
|
2707
|
+
pixi_projection.Euler = Euler;
|
2708
|
+
})(pixi_projection || (pixi_projection = {}));
|
2709
|
+
var pixi_projection;
|
2710
|
+
(function (pixi_projection) {
|
2711
|
+
var mat4id = [1, 0, 0, 0,
|
2712
|
+
0, 1, 0, 0,
|
2713
|
+
0, 0, 1, 0,
|
2714
|
+
0, 0, 0, 1];
|
2715
|
+
var Matrix3d = (function () {
|
2716
|
+
function Matrix3d(backingArray) {
|
2717
|
+
this.floatArray = null;
|
2718
|
+
this._dirtyId = 0;
|
2719
|
+
this._updateId = -1;
|
2720
|
+
this._mat4inv = null;
|
2721
|
+
this.cacheInverse = false;
|
2722
|
+
this.mat4 = new Float64Array(backingArray || mat4id);
|
2723
|
+
}
|
2724
|
+
Object.defineProperty(Matrix3d.prototype, "a", {
|
2725
|
+
get: function () {
|
2726
|
+
return this.mat4[0] / this.mat4[15];
|
2727
|
+
},
|
2728
|
+
set: function (value) {
|
2729
|
+
this.mat4[0] = value * this.mat4[15];
|
2730
|
+
},
|
2731
|
+
enumerable: true,
|
2732
|
+
configurable: true
|
2733
|
+
});
|
2734
|
+
Object.defineProperty(Matrix3d.prototype, "b", {
|
2735
|
+
get: function () {
|
2736
|
+
return this.mat4[1] / this.mat4[15];
|
2737
|
+
},
|
2738
|
+
set: function (value) {
|
2739
|
+
this.mat4[1] = value * this.mat4[15];
|
2740
|
+
},
|
2741
|
+
enumerable: true,
|
2742
|
+
configurable: true
|
2743
|
+
});
|
2744
|
+
Object.defineProperty(Matrix3d.prototype, "c", {
|
2745
|
+
get: function () {
|
2746
|
+
return this.mat4[4] / this.mat4[15];
|
2747
|
+
},
|
2748
|
+
set: function (value) {
|
2749
|
+
this.mat4[4] = value * this.mat4[15];
|
2750
|
+
},
|
2751
|
+
enumerable: true,
|
2752
|
+
configurable: true
|
2753
|
+
});
|
2754
|
+
Object.defineProperty(Matrix3d.prototype, "d", {
|
2755
|
+
get: function () {
|
2756
|
+
return this.mat4[5] / this.mat4[15];
|
2757
|
+
},
|
2758
|
+
set: function (value) {
|
2759
|
+
this.mat4[5] = value * this.mat4[15];
|
2760
|
+
},
|
2761
|
+
enumerable: true,
|
2762
|
+
configurable: true
|
2763
|
+
});
|
2764
|
+
Object.defineProperty(Matrix3d.prototype, "tx", {
|
2765
|
+
get: function () {
|
2766
|
+
return this.mat4[12] / this.mat4[15];
|
2767
|
+
},
|
2768
|
+
set: function (value) {
|
2769
|
+
this.mat4[12] = value * this.mat4[15];
|
2770
|
+
},
|
2771
|
+
enumerable: true,
|
2772
|
+
configurable: true
|
2773
|
+
});
|
2774
|
+
Object.defineProperty(Matrix3d.prototype, "ty", {
|
2775
|
+
get: function () {
|
2776
|
+
return this.mat4[13] / this.mat4[15];
|
2777
|
+
},
|
2778
|
+
set: function (value) {
|
2779
|
+
this.mat4[13] = value * this.mat4[15];
|
2780
|
+
},
|
2781
|
+
enumerable: true,
|
2782
|
+
configurable: true
|
2783
|
+
});
|
2784
|
+
Matrix3d.prototype.set = function (a, b, c, d, tx, ty) {
|
2785
|
+
var mat4 = this.mat4;
|
2786
|
+
mat4[0] = a;
|
2787
|
+
mat4[1] = b;
|
2788
|
+
mat4[2] = 0;
|
2789
|
+
mat4[3] = 0;
|
2790
|
+
mat4[4] = c;
|
2791
|
+
mat4[5] = d;
|
2792
|
+
mat4[6] = 0;
|
2793
|
+
mat4[7] = 0;
|
2794
|
+
mat4[8] = 0;
|
2795
|
+
mat4[9] = 0;
|
2796
|
+
mat4[10] = 1;
|
2797
|
+
mat4[11] = 0;
|
2798
|
+
mat4[12] = tx;
|
2799
|
+
mat4[13] = ty;
|
2800
|
+
mat4[14] = 0;
|
2801
|
+
mat4[15] = 1;
|
2802
|
+
return this;
|
2803
|
+
};
|
2804
|
+
Matrix3d.prototype.toArray = function (transpose, out) {
|
2805
|
+
if (!this.floatArray) {
|
2806
|
+
this.floatArray = new Float32Array(9);
|
2807
|
+
}
|
2808
|
+
var array = out || this.floatArray;
|
2809
|
+
var mat3 = this.mat4;
|
2810
|
+
if (transpose) {
|
2811
|
+
array[0] = mat3[0];
|
2812
|
+
array[1] = mat3[1];
|
2813
|
+
array[2] = mat3[3];
|
2814
|
+
array[3] = mat3[4];
|
2815
|
+
array[4] = mat3[5];
|
2816
|
+
array[5] = mat3[7];
|
2817
|
+
array[6] = mat3[12];
|
2818
|
+
array[7] = mat3[13];
|
2819
|
+
array[8] = mat3[15];
|
2820
|
+
}
|
2821
|
+
else {
|
2822
|
+
array[0] = mat3[0];
|
2823
|
+
array[1] = mat3[4];
|
2824
|
+
array[2] = mat3[12];
|
2825
|
+
array[3] = mat3[2];
|
2826
|
+
array[4] = mat3[6];
|
2827
|
+
array[5] = mat3[13];
|
2828
|
+
array[6] = mat3[3];
|
2829
|
+
array[7] = mat3[7];
|
2830
|
+
array[8] = mat3[15];
|
2831
|
+
}
|
2832
|
+
return array;
|
2833
|
+
};
|
2834
|
+
Matrix3d.prototype.setToTranslation = function (tx, ty, tz) {
|
2835
|
+
var mat4 = this.mat4;
|
2836
|
+
mat4[0] = 1;
|
2837
|
+
mat4[1] = 0;
|
2838
|
+
mat4[2] = 0;
|
2839
|
+
mat4[3] = 0;
|
2840
|
+
mat4[4] = 0;
|
2841
|
+
mat4[5] = 1;
|
2842
|
+
mat4[6] = 0;
|
2843
|
+
mat4[7] = 0;
|
2844
|
+
mat4[8] = 0;
|
2845
|
+
mat4[9] = 0;
|
2846
|
+
mat4[10] = 1;
|
2847
|
+
mat4[11] = 0;
|
2848
|
+
mat4[12] = tx;
|
2849
|
+
mat4[13] = ty;
|
2850
|
+
mat4[14] = tz;
|
2851
|
+
mat4[15] = 1;
|
2852
|
+
};
|
2853
|
+
Matrix3d.prototype.setToRotationTranslationScale = function (quat, tx, ty, tz, sx, sy, sz) {
|
2854
|
+
var out = this.mat4;
|
2855
|
+
var x = quat[0], y = quat[1], z = quat[2], w = quat[3];
|
2856
|
+
var x2 = x + x;
|
2857
|
+
var y2 = y + y;
|
2858
|
+
var z2 = z + z;
|
2859
|
+
var xx = x * x2;
|
2860
|
+
var xy = x * y2;
|
2861
|
+
var xz = x * z2;
|
2862
|
+
var yy = y * y2;
|
2863
|
+
var yz = y * z2;
|
2864
|
+
var zz = z * z2;
|
2865
|
+
var wx = w * x2;
|
2866
|
+
var wy = w * y2;
|
2867
|
+
var wz = w * z2;
|
2868
|
+
out[0] = (1 - (yy + zz)) * sx;
|
2869
|
+
out[1] = (xy + wz) * sx;
|
2870
|
+
out[2] = (xz - wy) * sx;
|
2871
|
+
out[3] = 0;
|
2872
|
+
out[4] = (xy - wz) * sy;
|
2873
|
+
out[5] = (1 - (xx + zz)) * sy;
|
2874
|
+
out[6] = (yz + wx) * sy;
|
2875
|
+
out[7] = 0;
|
2876
|
+
out[8] = (xz + wy) * sz;
|
2877
|
+
out[9] = (yz - wx) * sz;
|
2878
|
+
out[10] = (1 - (xx + yy)) * sz;
|
2879
|
+
out[11] = 0;
|
2880
|
+
out[12] = tx;
|
2881
|
+
out[13] = ty;
|
2882
|
+
out[14] = tz;
|
2883
|
+
out[15] = 1;
|
2884
|
+
return out;
|
2885
|
+
};
|
2886
|
+
Matrix3d.prototype.apply = function (pos, newPos) {
|
2887
|
+
newPos = newPos || new PIXI.Point();
|
2888
|
+
var mat4 = this.mat4;
|
2889
|
+
var x = pos.x;
|
2890
|
+
var y = pos.y;
|
2891
|
+
var z = pos.z;
|
2892
|
+
var w = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]);
|
2893
|
+
newPos.x = w * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]);
|
2894
|
+
newPos.y = w * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]);
|
2895
|
+
newPos.z = w * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]);
|
2896
|
+
return newPos;
|
2897
|
+
};
|
2898
|
+
Matrix3d.prototype.translate = function (tx, ty, tz) {
|
2899
|
+
var a = this.mat4;
|
2900
|
+
a[12] = a[0] * tx + a[4] * ty + a[8] * tz + a[12];
|
2901
|
+
a[13] = a[1] * tx + a[5] * ty + a[9] * tz + a[13];
|
2902
|
+
a[14] = a[2] * tx + a[6] * ty + a[10] * tz + a[14];
|
2903
|
+
a[15] = a[3] * tx + a[7] * ty + a[11] * tz + a[15];
|
2904
|
+
return this;
|
2905
|
+
};
|
2906
|
+
Matrix3d.prototype.scale = function (x, y, z) {
|
2907
|
+
var mat4 = this.mat4;
|
2908
|
+
mat4[0] *= x;
|
2909
|
+
mat4[1] *= x;
|
2910
|
+
mat4[2] *= x;
|
2911
|
+
mat4[3] *= x;
|
2912
|
+
mat4[4] *= y;
|
2913
|
+
mat4[5] *= y;
|
2914
|
+
mat4[6] *= y;
|
2915
|
+
mat4[7] *= y;
|
2916
|
+
if (z !== undefined) {
|
2917
|
+
mat4[8] *= z;
|
2918
|
+
mat4[9] *= z;
|
2919
|
+
mat4[10] *= z;
|
2920
|
+
mat4[11] *= z;
|
2921
|
+
}
|
2922
|
+
return this;
|
2923
|
+
};
|
2924
|
+
Matrix3d.prototype.scaleAndTranslate = function (scaleX, scaleY, scaleZ, tx, ty, tz) {
|
2925
|
+
var mat4 = this.mat4;
|
2926
|
+
mat4[0] = scaleX * mat4[0] + tx * mat4[3];
|
2927
|
+
mat4[1] = scaleY * mat4[1] + ty * mat4[3];
|
2928
|
+
mat4[2] = scaleZ * mat4[2] + tz * mat4[3];
|
2929
|
+
mat4[4] = scaleX * mat4[4] + tx * mat4[7];
|
2930
|
+
mat4[5] = scaleY * mat4[5] + ty * mat4[7];
|
2931
|
+
mat4[6] = scaleZ * mat4[6] + tz * mat4[7];
|
2932
|
+
mat4[8] = scaleX * mat4[8] + tx * mat4[11];
|
2933
|
+
mat4[9] = scaleY * mat4[9] + ty * mat4[11];
|
2934
|
+
mat4[10] = scaleZ * mat4[10] + tz * mat4[11];
|
2935
|
+
mat4[12] = scaleX * mat4[12] + tx * mat4[15];
|
2936
|
+
mat4[13] = scaleY * mat4[13] + ty * mat4[15];
|
2937
|
+
mat4[14] = scaleZ * mat4[14] + tz * mat4[15];
|
2938
|
+
};
|
2939
|
+
Matrix3d.prototype.applyInverse = function (pos, newPos) {
|
2940
|
+
newPos = newPos || new pixi_projection.Point3d();
|
2941
|
+
if (!this._mat4inv) {
|
2942
|
+
this._mat4inv = new Float64Array(16);
|
2943
|
+
}
|
2944
|
+
var mat4 = this._mat4inv;
|
2945
|
+
var a = this.mat4;
|
2946
|
+
var x = pos.x;
|
2947
|
+
var y = pos.y;
|
2948
|
+
var z = pos.z;
|
2949
|
+
if (!this.cacheInverse || this._updateId !== this._dirtyId) {
|
2950
|
+
this._updateId = this._dirtyId;
|
2951
|
+
Matrix3d.glMatrixMat4Invert(mat4, a);
|
2952
|
+
}
|
2953
|
+
var w1 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]);
|
2954
|
+
var x1 = w1 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]);
|
2955
|
+
var y1 = w1 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]);
|
2956
|
+
var z1 = w1 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]);
|
2957
|
+
z += 1.0;
|
2958
|
+
var w2 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]);
|
2959
|
+
var x2 = w2 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]);
|
2960
|
+
var y2 = w2 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]);
|
2961
|
+
var z2 = w2 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]);
|
2962
|
+
if (Math.abs(z1 - z2) < 1e-10) {
|
2963
|
+
newPos.set(NaN, NaN, 0);
|
2964
|
+
}
|
2965
|
+
var alpha = (0 - z1) / (z2 - z1);
|
2966
|
+
newPos.set((x2 - x1) * alpha + x1, (y2 - y1) * alpha + y1, 0.0);
|
2967
|
+
return newPos;
|
2968
|
+
};
|
2969
|
+
Matrix3d.prototype.invert = function () {
|
2970
|
+
Matrix3d.glMatrixMat4Invert(this.mat4, this.mat4);
|
2971
|
+
return this;
|
2972
|
+
};
|
2973
|
+
Matrix3d.prototype.invertCopyTo = function (matrix) {
|
2974
|
+
if (!this._mat4inv) {
|
2975
|
+
this._mat4inv = new Float64Array(16);
|
2976
|
+
}
|
2977
|
+
var mat4 = this._mat4inv;
|
2978
|
+
var a = this.mat4;
|
2979
|
+
if (!this.cacheInverse || this._updateId !== this._dirtyId) {
|
2980
|
+
this._updateId = this._dirtyId;
|
2981
|
+
Matrix3d.glMatrixMat4Invert(mat4, a);
|
2982
|
+
}
|
2983
|
+
matrix.mat4.set(mat4);
|
2984
|
+
};
|
2985
|
+
Matrix3d.prototype.identity = function () {
|
2986
|
+
var mat3 = this.mat4;
|
2987
|
+
mat3[0] = 1;
|
2988
|
+
mat3[1] = 0;
|
2989
|
+
mat3[2] = 0;
|
2990
|
+
mat3[3] = 0;
|
2991
|
+
mat3[4] = 0;
|
2992
|
+
mat3[5] = 1;
|
2993
|
+
mat3[6] = 0;
|
2994
|
+
mat3[7] = 0;
|
2995
|
+
mat3[8] = 0;
|
2996
|
+
mat3[9] = 0;
|
2997
|
+
mat3[10] = 1;
|
2998
|
+
mat3[11] = 0;
|
2999
|
+
mat3[12] = 0;
|
3000
|
+
mat3[13] = 0;
|
3001
|
+
mat3[14] = 0;
|
3002
|
+
mat3[15] = 1;
|
3003
|
+
return this;
|
3004
|
+
};
|
3005
|
+
Matrix3d.prototype.clone = function () {
|
3006
|
+
return new Matrix3d(this.mat4);
|
3007
|
+
};
|
3008
|
+
Matrix3d.prototype.copyTo = function (matrix) {
|
3009
|
+
var mat3 = this.mat4;
|
3010
|
+
var ar2 = matrix.mat4;
|
3011
|
+
ar2[0] = mat3[0];
|
3012
|
+
ar2[1] = mat3[1];
|
3013
|
+
ar2[2] = mat3[2];
|
3014
|
+
ar2[3] = mat3[3];
|
3015
|
+
ar2[4] = mat3[4];
|
3016
|
+
ar2[5] = mat3[5];
|
3017
|
+
ar2[6] = mat3[6];
|
3018
|
+
ar2[7] = mat3[7];
|
3019
|
+
ar2[8] = mat3[8];
|
3020
|
+
return matrix;
|
3021
|
+
};
|
3022
|
+
Matrix3d.prototype.copy = function (matrix, affine) {
|
3023
|
+
var mat3 = this.mat4;
|
3024
|
+
var d = 1.0 / mat3[15];
|
3025
|
+
var tx = mat3[12] * d, ty = mat3[13] * d;
|
3026
|
+
matrix.a = (mat3[0] - mat3[3] * tx) * d;
|
3027
|
+
matrix.b = (mat3[1] - mat3[3] * ty) * d;
|
3028
|
+
matrix.c = (mat3[4] - mat3[7] * tx) * d;
|
3029
|
+
matrix.d = (mat3[5] - mat3[7] * ty) * d;
|
3030
|
+
matrix.tx = tx;
|
3031
|
+
matrix.ty = ty;
|
3032
|
+
if (affine >= 2) {
|
3033
|
+
if (affine === pixi_projection.AFFINE.POINT) {
|
3034
|
+
matrix.a = 1;
|
3035
|
+
matrix.b = 0;
|
3036
|
+
matrix.c = 0;
|
3037
|
+
matrix.d = 1;
|
3038
|
+
}
|
3039
|
+
else if (affine === pixi_projection.AFFINE.AXIS_X) {
|
3040
|
+
matrix.c = -matrix.b;
|
3041
|
+
matrix.d = matrix.a;
|
3042
|
+
}
|
3043
|
+
else if (affine === pixi_projection.AFFINE.AXIS_Y) {
|
3044
|
+
matrix.a = matrix.d;
|
3045
|
+
matrix.c = -matrix.b;
|
3046
|
+
}
|
3047
|
+
}
|
3048
|
+
};
|
3049
|
+
Matrix3d.prototype.copyFrom = function (matrix) {
|
3050
|
+
var mat3 = this.mat4;
|
3051
|
+
mat3[0] = matrix.a;
|
3052
|
+
mat3[1] = matrix.b;
|
3053
|
+
mat3[2] = 0;
|
3054
|
+
mat3[3] = 0;
|
3055
|
+
mat3[4] = matrix.c;
|
3056
|
+
mat3[5] = matrix.d;
|
3057
|
+
mat3[6] = 0;
|
3058
|
+
mat3[7] = 0;
|
3059
|
+
mat3[8] = 0;
|
3060
|
+
mat3[9] = 0;
|
3061
|
+
mat3[10] = 1;
|
3062
|
+
mat3[11] = 0;
|
3063
|
+
mat3[12] = matrix.tx;
|
3064
|
+
mat3[13] = matrix.ty;
|
3065
|
+
mat3[14] = 0;
|
3066
|
+
mat3[15] = 1;
|
3067
|
+
this._dirtyId++;
|
3068
|
+
return this;
|
3069
|
+
};
|
3070
|
+
Matrix3d.prototype.setToMultLegacy = function (pt, lt) {
|
3071
|
+
var out = this.mat4;
|
3072
|
+
var b = lt.mat4;
|
3073
|
+
var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a30 = pt.tx, a31 = pt.ty;
|
3074
|
+
var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
|
3075
|
+
out[0] = b0 * a00 + b1 * a10 + b3 * a30;
|
3076
|
+
out[1] = b0 * a01 + b1 * a11 + b3 * a31;
|
3077
|
+
out[2] = b2;
|
3078
|
+
out[3] = b3;
|
3079
|
+
b0 = b[4];
|
3080
|
+
b1 = b[5];
|
3081
|
+
b2 = b[6];
|
3082
|
+
b3 = b[7];
|
3083
|
+
out[4] = b0 * a00 + b1 * a10 + b3 * a30;
|
3084
|
+
out[5] = b0 * a01 + b1 * a11 + b3 * a31;
|
3085
|
+
out[6] = b2;
|
3086
|
+
out[7] = b3;
|
3087
|
+
b0 = b[8];
|
3088
|
+
b1 = b[9];
|
3089
|
+
b2 = b[10];
|
3090
|
+
b3 = b[11];
|
3091
|
+
out[8] = b0 * a00 + b1 * a10 + b3 * a30;
|
3092
|
+
out[9] = b0 * a01 + b1 * a11 + b3 * a31;
|
3093
|
+
out[10] = b2;
|
3094
|
+
out[11] = b3;
|
3095
|
+
b0 = b[12];
|
3096
|
+
b1 = b[13];
|
3097
|
+
b2 = b[14];
|
3098
|
+
b3 = b[15];
|
3099
|
+
out[12] = b0 * a00 + b1 * a10 + b3 * a30;
|
3100
|
+
out[13] = b0 * a01 + b1 * a11 + b3 * a31;
|
3101
|
+
out[14] = b2;
|
3102
|
+
out[15] = b3;
|
3103
|
+
this._dirtyId++;
|
3104
|
+
return this;
|
3105
|
+
};
|
3106
|
+
Matrix3d.prototype.setToMultLegacy2 = function (pt, lt) {
|
3107
|
+
var out = this.mat4;
|
3108
|
+
var a = pt.mat4;
|
3109
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
|
3110
|
+
var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
|
3111
|
+
var b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b30 = lt.tx, b31 = lt.ty;
|
3112
|
+
out[0] = b00 * a00 + b01 * a10;
|
3113
|
+
out[1] = b00 * a01 + b01 * a11;
|
3114
|
+
out[2] = b00 * a02 + b01 * a12;
|
3115
|
+
out[3] = b00 * a03 + b01 * a13;
|
3116
|
+
out[4] = b10 * a00 + b11 * a10;
|
3117
|
+
out[5] = b10 * a01 + b11 * a11;
|
3118
|
+
out[6] = b10 * a02 + b11 * a12;
|
3119
|
+
out[7] = b10 * a03 + b11 * a13;
|
3120
|
+
out[8] = a[8];
|
3121
|
+
out[9] = a[9];
|
3122
|
+
out[10] = a[10];
|
3123
|
+
out[11] = a[11];
|
3124
|
+
out[12] = b30 * a00 + b31 * a10 + a[12];
|
3125
|
+
out[13] = b30 * a01 + b31 * a11 + a[13];
|
3126
|
+
out[14] = b30 * a02 + b31 * a12 + a[14];
|
3127
|
+
out[15] = b30 * a03 + b31 * a13 + a[15];
|
3128
|
+
this._dirtyId++;
|
3129
|
+
return this;
|
3130
|
+
};
|
3131
|
+
Matrix3d.prototype.setToMult = function (pt, lt) {
|
3132
|
+
Matrix3d.glMatrixMat4Multiply(this.mat4, pt.mat4, lt.mat4);
|
3133
|
+
this._dirtyId++;
|
3134
|
+
return this;
|
3135
|
+
};
|
3136
|
+
Matrix3d.prototype.prepend = function (lt) {
|
3137
|
+
if (lt.mat4) {
|
3138
|
+
this.setToMult(lt, this);
|
3139
|
+
}
|
3140
|
+
else {
|
3141
|
+
this.setToMultLegacy(lt, this);
|
3142
|
+
}
|
3143
|
+
};
|
3144
|
+
Matrix3d.glMatrixMat4Invert = function (out, a) {
|
3145
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
|
3146
|
+
var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
|
3147
|
+
var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
|
3148
|
+
var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
|
3149
|
+
var b00 = a00 * a11 - a01 * a10;
|
3150
|
+
var b01 = a00 * a12 - a02 * a10;
|
3151
|
+
var b02 = a00 * a13 - a03 * a10;
|
3152
|
+
var b03 = a01 * a12 - a02 * a11;
|
3153
|
+
var b04 = a01 * a13 - a03 * a11;
|
3154
|
+
var b05 = a02 * a13 - a03 * a12;
|
3155
|
+
var b06 = a20 * a31 - a21 * a30;
|
3156
|
+
var b07 = a20 * a32 - a22 * a30;
|
3157
|
+
var b08 = a20 * a33 - a23 * a30;
|
3158
|
+
var b09 = a21 * a32 - a22 * a31;
|
3159
|
+
var b10 = a21 * a33 - a23 * a31;
|
3160
|
+
var b11 = a22 * a33 - a23 * a32;
|
3161
|
+
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
3162
|
+
if (!det) {
|
3163
|
+
return null;
|
3164
|
+
}
|
3165
|
+
det = 1.0 / det;
|
3166
|
+
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
3167
|
+
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
3168
|
+
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
3169
|
+
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
3170
|
+
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
3171
|
+
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
3172
|
+
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
3173
|
+
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
3174
|
+
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
3175
|
+
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
3176
|
+
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
3177
|
+
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
3178
|
+
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
3179
|
+
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
3180
|
+
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
3181
|
+
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
3182
|
+
return out;
|
3183
|
+
};
|
3184
|
+
Matrix3d.glMatrixMat4Multiply = function (out, a, b) {
|
3185
|
+
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
|
3186
|
+
var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
|
3187
|
+
var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
|
3188
|
+
var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
|
3189
|
+
var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
|
3190
|
+
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
3191
|
+
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
3192
|
+
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
3193
|
+
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
3194
|
+
b0 = b[4];
|
3195
|
+
b1 = b[5];
|
3196
|
+
b2 = b[6];
|
3197
|
+
b3 = b[7];
|
3198
|
+
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
3199
|
+
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
3200
|
+
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
3201
|
+
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
3202
|
+
b0 = b[8];
|
3203
|
+
b1 = b[9];
|
3204
|
+
b2 = b[10];
|
3205
|
+
b3 = b[11];
|
3206
|
+
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
3207
|
+
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
3208
|
+
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
3209
|
+
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
3210
|
+
b0 = b[12];
|
3211
|
+
b1 = b[13];
|
3212
|
+
b2 = b[14];
|
3213
|
+
b3 = b[15];
|
3214
|
+
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
3215
|
+
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
3216
|
+
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
3217
|
+
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
3218
|
+
return out;
|
3219
|
+
};
|
3220
|
+
Matrix3d.IDENTITY = new Matrix3d();
|
3221
|
+
Matrix3d.TEMP_MATRIX = new Matrix3d();
|
3222
|
+
return Matrix3d;
|
3223
|
+
}());
|
3224
|
+
pixi_projection.Matrix3d = Matrix3d;
|
3225
|
+
})(pixi_projection || (pixi_projection = {}));
|
3226
|
+
var pixi_projection;
|
3227
|
+
(function (pixi_projection) {
|
3228
|
+
var ObservableEuler = (function () {
|
3229
|
+
function ObservableEuler(cb, scope, x, y, z) {
|
3230
|
+
this.cb = cb;
|
3231
|
+
this.scope = scope;
|
3232
|
+
this._quatUpdateId = -1;
|
3233
|
+
this._quatDirtyId = 0;
|
3234
|
+
this._sign = 1;
|
3235
|
+
this._x = x || 0;
|
3236
|
+
this._y = y || 0;
|
3237
|
+
this._z = z || 0;
|
3238
|
+
this.quaternion = new Float64Array(4);
|
3239
|
+
this.quaternion[3] = 1;
|
3240
|
+
this.update();
|
3241
|
+
}
|
3242
|
+
Object.defineProperty(ObservableEuler.prototype, "x", {
|
3243
|
+
get: function () {
|
3244
|
+
return this._x;
|
3245
|
+
},
|
3246
|
+
set: function (value) {
|
3247
|
+
if (this._x !== value) {
|
3248
|
+
this._x = value;
|
3249
|
+
this._quatDirtyId++;
|
3250
|
+
this.cb.call(this.scope);
|
3251
|
+
}
|
3252
|
+
},
|
3253
|
+
enumerable: true,
|
3254
|
+
configurable: true
|
3255
|
+
});
|
3256
|
+
Object.defineProperty(ObservableEuler.prototype, "y", {
|
3257
|
+
get: function () {
|
3258
|
+
return this._y;
|
3259
|
+
},
|
3260
|
+
set: function (value) {
|
3261
|
+
if (this._y !== value) {
|
3262
|
+
this._y = value;
|
3263
|
+
this._quatDirtyId++;
|
3264
|
+
this.cb.call(this.scope);
|
3265
|
+
}
|
3266
|
+
},
|
3267
|
+
enumerable: true,
|
3268
|
+
configurable: true
|
3269
|
+
});
|
3270
|
+
Object.defineProperty(ObservableEuler.prototype, "z", {
|
3271
|
+
get: function () {
|
3272
|
+
return this._z;
|
3273
|
+
},
|
3274
|
+
set: function (value) {
|
3275
|
+
if (this._z !== value) {
|
3276
|
+
this._z = value;
|
3277
|
+
this._quatDirtyId++;
|
3278
|
+
this.cb.call(this.scope);
|
3279
|
+
}
|
3280
|
+
},
|
3281
|
+
enumerable: true,
|
3282
|
+
configurable: true
|
3283
|
+
});
|
3284
|
+
Object.defineProperty(ObservableEuler.prototype, "pitch", {
|
3285
|
+
get: function () {
|
3286
|
+
return this._x;
|
3287
|
+
},
|
3288
|
+
set: function (value) {
|
3289
|
+
if (this._x !== value) {
|
3290
|
+
this._x = value;
|
3291
|
+
this._quatDirtyId++;
|
3292
|
+
this.cb.call(this.scope);
|
3293
|
+
}
|
3294
|
+
},
|
3295
|
+
enumerable: true,
|
3296
|
+
configurable: true
|
3297
|
+
});
|
3298
|
+
Object.defineProperty(ObservableEuler.prototype, "yaw", {
|
3299
|
+
get: function () {
|
3300
|
+
return this._y;
|
3301
|
+
},
|
3302
|
+
set: function (value) {
|
3303
|
+
if (this._y !== value) {
|
3304
|
+
this._y = value;
|
3305
|
+
this._quatDirtyId++;
|
3306
|
+
this.cb.call(this.scope);
|
3307
|
+
}
|
3308
|
+
},
|
3309
|
+
enumerable: true,
|
3310
|
+
configurable: true
|
3311
|
+
});
|
3312
|
+
Object.defineProperty(ObservableEuler.prototype, "roll", {
|
3313
|
+
get: function () {
|
3314
|
+
return this._z;
|
3315
|
+
},
|
3316
|
+
set: function (value) {
|
3317
|
+
if (this._z !== value) {
|
3318
|
+
this._z = value;
|
3319
|
+
this._quatDirtyId++;
|
3320
|
+
this.cb.call(this.scope);
|
3321
|
+
}
|
3322
|
+
},
|
3323
|
+
enumerable: true,
|
3324
|
+
configurable: true
|
3325
|
+
});
|
3326
|
+
ObservableEuler.prototype.set = function (x, y, z) {
|
3327
|
+
var _x = x || 0;
|
3328
|
+
var _y = y || 0;
|
3329
|
+
var _z = z || 0;
|
3330
|
+
if (this._x !== _x || this._y !== _y || this._z !== _z) {
|
3331
|
+
this._x = _x;
|
3332
|
+
this._y = _y;
|
3333
|
+
this._z = _z;
|
3334
|
+
this._quatDirtyId++;
|
3335
|
+
this.cb.call(this.scope);
|
3336
|
+
}
|
3337
|
+
};
|
3338
|
+
;
|
3339
|
+
ObservableEuler.prototype.copy = function (euler) {
|
3340
|
+
var _x = euler.x;
|
3341
|
+
var _y = euler.y;
|
3342
|
+
var _z = euler.z;
|
3343
|
+
if (this._x !== _x || this._y !== _y || this._z !== _z) {
|
3344
|
+
this._x = _x;
|
3345
|
+
this._y = _y;
|
3346
|
+
this._z = _z;
|
3347
|
+
this._quatDirtyId++;
|
3348
|
+
this.cb.call(this.scope);
|
3349
|
+
}
|
3350
|
+
};
|
3351
|
+
ObservableEuler.prototype.clone = function () {
|
3352
|
+
return new pixi_projection.Euler(this._x, this._y, this._z);
|
3353
|
+
};
|
3354
|
+
ObservableEuler.prototype.update = function () {
|
3355
|
+
if (this._quatUpdateId === this._quatDirtyId) {
|
3356
|
+
return false;
|
3357
|
+
}
|
3358
|
+
this._quatUpdateId = this._quatDirtyId;
|
3359
|
+
var c1 = Math.cos(this._x / 2);
|
3360
|
+
var c2 = Math.cos(this._y / 2);
|
3361
|
+
var c3 = Math.cos(this._z / 2);
|
3362
|
+
var s = this._sign;
|
3363
|
+
var s1 = s * Math.sin(this._x / 2);
|
3364
|
+
var s2 = s * Math.sin(this._y / 2);
|
3365
|
+
var s3 = s * Math.sin(this._z / 2);
|
3366
|
+
var q = this.quaternion;
|
3367
|
+
q[0] = s1 * c2 * c3 + c1 * s2 * s3;
|
3368
|
+
q[1] = c1 * s2 * c3 - s1 * c2 * s3;
|
3369
|
+
q[2] = c1 * c2 * s3 + s1 * s2 * c3;
|
3370
|
+
q[3] = c1 * c2 * c3 - s1 * s2 * s3;
|
3371
|
+
return true;
|
3372
|
+
};
|
3373
|
+
return ObservableEuler;
|
3374
|
+
}());
|
3375
|
+
pixi_projection.ObservableEuler = ObservableEuler;
|
3376
|
+
})(pixi_projection || (pixi_projection = {}));
|
3377
|
+
var pixi_projection;
|
3378
|
+
(function (pixi_projection) {
|
3379
|
+
PIXI.Point.prototype.z = 0;
|
3380
|
+
PIXI.Point.prototype.set = function (x, y, z) {
|
3381
|
+
this.x = x || 0;
|
3382
|
+
this.y = (y === undefined) ? this.x : (y || 0);
|
3383
|
+
this.z = (y === undefined) ? this.x : (z || 0);
|
3384
|
+
};
|
3385
|
+
PIXI.Point.prototype.copy = function (p) {
|
3386
|
+
this.set(p.x, p.y, p.z);
|
3387
|
+
};
|
3388
|
+
PIXI.ObservablePoint.prototype._z = 0;
|
3389
|
+
PIXI.ObservablePoint.prototype.set = function (x, y, z) {
|
3390
|
+
var _x = x || 0;
|
3391
|
+
var _y = (y === undefined) ? _x : (y || 0);
|
3392
|
+
var _z = (y === undefined) ? _x : (z || 0);
|
3393
|
+
if (this._x !== _x || this._y !== _y || this._z !== _z) {
|
3394
|
+
this._x = _x;
|
3395
|
+
this._y = _y;
|
3396
|
+
this._z = _z;
|
3397
|
+
this.cb.call(this.scope);
|
3398
|
+
}
|
3399
|
+
};
|
3400
|
+
Object.defineProperty(PIXI.ObservablePoint.prototype, "z", {
|
3401
|
+
get: function () {
|
3402
|
+
return this._z;
|
3403
|
+
},
|
3404
|
+
set: function (value) {
|
3405
|
+
if (this._z !== value) {
|
3406
|
+
this._z = value;
|
3407
|
+
this.cb.call(this.scope);
|
3408
|
+
}
|
3409
|
+
},
|
3410
|
+
enumerable: true,
|
3411
|
+
configurable: true
|
3412
|
+
});
|
3413
|
+
PIXI.ObservablePoint.prototype.copy = function (point) {
|
3414
|
+
if (this._x !== point.x || this._y !== point.y || this._z !== point.z) {
|
3415
|
+
this._x = point.x;
|
3416
|
+
this._y = point.y;
|
3417
|
+
this._z = point.z;
|
3418
|
+
this.cb.call(this.scope);
|
3419
|
+
}
|
3420
|
+
};
|
3421
|
+
var Point3d = (function (_super) {
|
3422
|
+
__extends(Point3d, _super);
|
3423
|
+
function Point3d(x, y, z) {
|
3424
|
+
var _this = _super.call(this, x, y) || this;
|
3425
|
+
_this.z = z;
|
3426
|
+
return _this;
|
3427
|
+
}
|
3428
|
+
return Point3d;
|
3429
|
+
}(PIXI.Point));
|
3430
|
+
pixi_projection.Point3d = Point3d;
|
3431
|
+
PIXI.Point = Point3d;
|
3432
|
+
})(pixi_projection || (pixi_projection = {}));
|
3433
|
+
var pixi_projection;
|
3434
|
+
(function (pixi_projection) {
|
3435
|
+
var tempMat = new pixi_projection.Matrix3d();
|
3436
|
+
var Projection3d = (function (_super) {
|
3437
|
+
__extends(Projection3d, _super);
|
3438
|
+
function Projection3d(legacy, enable) {
|
3439
|
+
var _this = _super.call(this, legacy, enable) || this;
|
3440
|
+
_this.cameraMatrix = null;
|
3441
|
+
_this._cameraMode = false;
|
3442
|
+
_this.position = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0);
|
3443
|
+
_this.scale = new PIXI.ObservablePoint(_this.onChange, _this, 1, 1);
|
3444
|
+
_this.euler = new pixi_projection.ObservableEuler(_this.onChange, _this, 0, 0, 0);
|
3445
|
+
_this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0);
|
3446
|
+
_this.local = new pixi_projection.Matrix3d();
|
3447
|
+
_this.world = new pixi_projection.Matrix3d();
|
3448
|
+
_this.local.cacheInverse = true;
|
3449
|
+
_this.world.cacheInverse = true;
|
3450
|
+
_this.position._z = 0;
|
3451
|
+
_this.scale._z = 1;
|
3452
|
+
_this.pivot._z = 0;
|
3453
|
+
return _this;
|
3454
|
+
}
|
3455
|
+
Object.defineProperty(Projection3d.prototype, "cameraMode", {
|
3456
|
+
get: function () {
|
3457
|
+
return this._cameraMode;
|
3458
|
+
},
|
3459
|
+
set: function (value) {
|
3460
|
+
if (this._cameraMode === value) {
|
3461
|
+
return;
|
3462
|
+
}
|
3463
|
+
this._cameraMode = value;
|
3464
|
+
this.euler._sign = this._cameraMode ? -1 : 1;
|
3465
|
+
this.euler._quatDirtyId++;
|
3466
|
+
if (value) {
|
3467
|
+
this.cameraMatrix = new pixi_projection.Matrix3d();
|
3468
|
+
}
|
3469
|
+
},
|
3470
|
+
enumerable: true,
|
3471
|
+
configurable: true
|
3472
|
+
});
|
3473
|
+
Projection3d.prototype.onChange = function () {
|
3474
|
+
this._projID++;
|
3475
|
+
};
|
3476
|
+
Projection3d.prototype.clear = function () {
|
3477
|
+
if (this.cameraMatrix) {
|
3478
|
+
this.cameraMatrix.identity();
|
3479
|
+
}
|
3480
|
+
this.position.set(0, 0, 0);
|
3481
|
+
this.scale.set(1, 1, 1);
|
3482
|
+
this.euler.set(0, 0, 0);
|
3483
|
+
this.pivot.set(0, 0, 0);
|
3484
|
+
_super.prototype.clear.call(this);
|
3485
|
+
};
|
3486
|
+
Projection3d.prototype.updateLocalTransform = function (lt) {
|
3487
|
+
if (this._projID === 0) {
|
3488
|
+
this.local.copyFrom(lt);
|
3489
|
+
return;
|
3490
|
+
}
|
3491
|
+
var matrix = this.local;
|
3492
|
+
var euler = this.euler;
|
3493
|
+
var pos = this.position;
|
3494
|
+
var scale = this.scale;
|
3495
|
+
var pivot = this.pivot;
|
3496
|
+
euler.update();
|
3497
|
+
if (!this.cameraMode) {
|
3498
|
+
matrix.setToRotationTranslationScale(euler.quaternion, pos._x, pos._y, pos._z, scale._x, scale._y, scale._z);
|
3499
|
+
matrix.translate(-pivot._x, -pivot._y, -pivot._z);
|
3500
|
+
matrix.setToMultLegacy(lt, matrix);
|
3501
|
+
return;
|
3502
|
+
}
|
3503
|
+
matrix.setToMultLegacy(lt, this.cameraMatrix);
|
3504
|
+
matrix.translate(pivot._x, pivot._y, pivot._z);
|
3505
|
+
matrix.scale(1.0 / scale._x, 1.0 / scale._y, 1.0 / scale._z);
|
3506
|
+
tempMat.setToRotationTranslationScale(euler.quaternion, 0, 0, 0, 1, 1, 1);
|
3507
|
+
matrix.setToMult(matrix, tempMat);
|
3508
|
+
matrix.translate(-pos._x, -pos._y, -pos._z);
|
3509
|
+
this.local._dirtyId++;
|
3510
|
+
};
|
3511
|
+
return Projection3d;
|
3512
|
+
}(pixi_projection.LinearProjection));
|
3513
|
+
pixi_projection.Projection3d = Projection3d;
|
3514
|
+
})(pixi_projection || (pixi_projection = {}));
|
3515
|
+
var pixi_projection;
|
3516
|
+
(function (pixi_projection) {
|
3517
|
+
var Mesh3d = (function (_super) {
|
3518
|
+
__extends(Mesh3d, _super);
|
3519
|
+
function Mesh3d(texture, vertices, uvs, indices, drawMode) {
|
3520
|
+
var _this = _super.call(this, texture, vertices, uvs, indices, drawMode) || this;
|
3521
|
+
_this.proj = new pixi_projection.Projection3d(_this.transform);
|
3522
|
+
_this.pluginName = 'mesh2d';
|
3523
|
+
return _this;
|
3524
|
+
}
|
3525
|
+
Object.defineProperty(Mesh3d.prototype, "worldTransform", {
|
3526
|
+
get: function () {
|
3527
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
3528
|
+
},
|
3529
|
+
enumerable: true,
|
3530
|
+
configurable: true
|
3531
|
+
});
|
3532
|
+
Mesh3d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
3533
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
3534
|
+
return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step);
|
3535
|
+
};
|
3536
|
+
Mesh3d.prototype.isFrontFace = function (forceUpdate) {
|
3537
|
+
return pixi_projection.container3dIsFrontFace.call(this, forceUpdate);
|
3538
|
+
};
|
3539
|
+
Mesh3d.prototype.getDepth = function (forceUpdate) {
|
3540
|
+
return pixi_projection.container3dGetDepth.call(this, forceUpdate);
|
3541
|
+
};
|
3542
|
+
Object.defineProperty(Mesh3d.prototype, "position3d", {
|
3543
|
+
get: function () {
|
3544
|
+
return this.proj.position;
|
3545
|
+
},
|
3546
|
+
set: function (value) {
|
3547
|
+
this.proj.position.copy(value);
|
3548
|
+
},
|
3549
|
+
enumerable: true,
|
3550
|
+
configurable: true
|
3551
|
+
});
|
3552
|
+
Object.defineProperty(Mesh3d.prototype, "scale3d", {
|
3553
|
+
get: function () {
|
3554
|
+
return this.proj.scale;
|
3555
|
+
},
|
3556
|
+
set: function (value) {
|
3557
|
+
this.proj.scale.copy(value);
|
3558
|
+
},
|
3559
|
+
enumerable: true,
|
3560
|
+
configurable: true
|
3561
|
+
});
|
3562
|
+
Object.defineProperty(Mesh3d.prototype, "euler", {
|
3563
|
+
get: function () {
|
3564
|
+
return this.proj.euler;
|
3565
|
+
},
|
3566
|
+
set: function (value) {
|
3567
|
+
this.proj.euler.copy(value);
|
3568
|
+
},
|
3569
|
+
enumerable: true,
|
3570
|
+
configurable: true
|
3571
|
+
});
|
3572
|
+
Object.defineProperty(Mesh3d.prototype, "pivot3d", {
|
3573
|
+
get: function () {
|
3574
|
+
return this.proj.pivot;
|
3575
|
+
},
|
3576
|
+
set: function (value) {
|
3577
|
+
this.proj.pivot.copy(value);
|
3578
|
+
},
|
3579
|
+
enumerable: true,
|
3580
|
+
configurable: true
|
3581
|
+
});
|
3582
|
+
return Mesh3d;
|
3583
|
+
}(PIXI.mesh.Mesh));
|
3584
|
+
pixi_projection.Mesh3d = Mesh3d;
|
3585
|
+
})(pixi_projection || (pixi_projection = {}));
|
3586
|
+
var pixi_projection;
|
3587
|
+
(function (pixi_projection) {
|
3588
|
+
var Sprite3d = (function (_super) {
|
3589
|
+
__extends(Sprite3d, _super);
|
3590
|
+
function Sprite3d(texture) {
|
3591
|
+
var _this = _super.call(this, texture) || this;
|
3592
|
+
_this.culledByFrustrum = false;
|
3593
|
+
_this.trimmedCulledByFrustrum = false;
|
3594
|
+
_this.proj = new pixi_projection.Projection3d(_this.transform);
|
3595
|
+
_this.pluginName = 'sprite2d';
|
3596
|
+
_this.vertexData = new Float32Array(12);
|
3597
|
+
return _this;
|
3598
|
+
}
|
3599
|
+
Sprite3d.prototype._calculateBounds = function () {
|
3600
|
+
this.calculateVertices();
|
3601
|
+
if (this.culledByFrustrum) {
|
3602
|
+
return;
|
3603
|
+
}
|
3604
|
+
this.calculateTrimmedVertices();
|
3605
|
+
if (!this.trimmedCulledByFrustrum) {
|
3606
|
+
this._bounds.addQuad(this.vertexTrimmedData);
|
3607
|
+
}
|
3608
|
+
};
|
3609
|
+
Sprite3d.prototype.calculateVertices = function () {
|
3610
|
+
if (this.proj._affine) {
|
3611
|
+
if (this.vertexData.length != 8) {
|
3612
|
+
this.vertexData = new Float32Array(8);
|
3613
|
+
}
|
3614
|
+
_super.prototype.calculateVertices.call(this);
|
3615
|
+
return;
|
3616
|
+
}
|
3617
|
+
if (this.vertexData.length != 12) {
|
3618
|
+
this.vertexData = new Float32Array(12);
|
3619
|
+
}
|
3620
|
+
var wid = this.transform._worldID;
|
3621
|
+
var tuid = this._texture._updateID;
|
3622
|
+
if (this._transformID === wid && this._textureID === tuid) {
|
3623
|
+
return;
|
3624
|
+
}
|
3625
|
+
this._transformID = wid;
|
3626
|
+
this._textureID = tuid;
|
3627
|
+
var texture = this._texture;
|
3628
|
+
var wt = this.proj.world.mat4;
|
3629
|
+
var vertexData = this.vertexData;
|
3630
|
+
var trim = texture.trim;
|
3631
|
+
var orig = texture.orig;
|
3632
|
+
var anchor = this._anchor;
|
3633
|
+
var w0 = 0;
|
3634
|
+
var w1 = 0;
|
3635
|
+
var h0 = 0;
|
3636
|
+
var h1 = 0;
|
3637
|
+
if (trim) {
|
3638
|
+
w1 = trim.x - (anchor._x * orig.width);
|
3639
|
+
w0 = w1 + trim.width;
|
3640
|
+
h1 = trim.y - (anchor._y * orig.height);
|
3641
|
+
h0 = h1 + trim.height;
|
3642
|
+
}
|
3643
|
+
else {
|
3644
|
+
w1 = -anchor._x * orig.width;
|
3645
|
+
w0 = w1 + orig.width;
|
3646
|
+
h1 = -anchor._y * orig.height;
|
3647
|
+
h0 = h1 + orig.height;
|
3648
|
+
}
|
3649
|
+
var culled = false;
|
3650
|
+
var z;
|
3651
|
+
vertexData[0] = (wt[0] * w1) + (wt[4] * h1) + wt[12];
|
3652
|
+
vertexData[1] = (wt[1] * w1) + (wt[5] * h1) + wt[13];
|
3653
|
+
z = (wt[2] * w1) + (wt[6] * h1) + wt[14];
|
3654
|
+
vertexData[2] = (wt[3] * w1) + (wt[7] * h1) + wt[15];
|
3655
|
+
culled = culled || z < 0;
|
3656
|
+
vertexData[3] = (wt[0] * w0) + (wt[4] * h1) + wt[12];
|
3657
|
+
vertexData[4] = (wt[1] * w0) + (wt[5] * h1) + wt[13];
|
3658
|
+
z = (wt[2] * w0) + (wt[6] * h1) + wt[14];
|
3659
|
+
vertexData[5] = (wt[3] * w0) + (wt[7] * h1) + wt[15];
|
3660
|
+
culled = culled || z < 0;
|
3661
|
+
vertexData[6] = (wt[0] * w0) + (wt[4] * h0) + wt[12];
|
3662
|
+
vertexData[7] = (wt[1] * w0) + (wt[5] * h0) + wt[13];
|
3663
|
+
z = (wt[2] * w0) + (wt[6] * h0) + wt[14];
|
3664
|
+
vertexData[8] = (wt[3] * w0) + (wt[7] * h0) + wt[15];
|
3665
|
+
culled = culled || z < 0;
|
3666
|
+
vertexData[9] = (wt[0] * w1) + (wt[4] * h0) + wt[12];
|
3667
|
+
vertexData[10] = (wt[1] * w1) + (wt[5] * h0) + wt[13];
|
3668
|
+
z = (wt[2] * w1) + (wt[6] * h0) + wt[14];
|
3669
|
+
vertexData[11] = (wt[3] * w1) + (wt[7] * h0) + wt[15];
|
3670
|
+
culled = culled || z < 0;
|
3671
|
+
this.culledByFrustrum = culled;
|
3672
|
+
};
|
3673
|
+
Sprite3d.prototype.calculateTrimmedVertices = function () {
|
3674
|
+
if (this.proj._affine) {
|
3675
|
+
_super.prototype.calculateTrimmedVertices.call(this);
|
3676
|
+
return;
|
3677
|
+
}
|
3678
|
+
var wid = this.transform._worldID;
|
3679
|
+
var tuid = this._texture._updateID;
|
3680
|
+
if (!this.vertexTrimmedData) {
|
3681
|
+
this.vertexTrimmedData = new Float32Array(8);
|
3682
|
+
}
|
3683
|
+
else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) {
|
3684
|
+
return;
|
3685
|
+
}
|
3686
|
+
this._transformTrimmedID = wid;
|
3687
|
+
this._textureTrimmedID = tuid;
|
3688
|
+
var texture = this._texture;
|
3689
|
+
var vertexData = this.vertexTrimmedData;
|
3690
|
+
var orig = texture.orig;
|
3691
|
+
var anchor = this._anchor;
|
3692
|
+
var wt = this.proj.world.mat4;
|
3693
|
+
var w1 = -anchor._x * orig.width;
|
3694
|
+
var w0 = w1 + orig.width;
|
3695
|
+
var h1 = -anchor._y * orig.height;
|
3696
|
+
var h0 = h1 + orig.height;
|
3697
|
+
var culled = false;
|
3698
|
+
var w = 1.0 / (wt[3] * w1 + wt[7] * h1 + wt[15]);
|
3699
|
+
vertexData[0] = w * ((wt[0] * w1) + (wt[4] * h1) + wt[12]);
|
3700
|
+
vertexData[1] = w * ((wt[1] * w1) + (wt[5] * h1) + wt[13]);
|
3701
|
+
var z = (wt[2] * w1) + (wt[6] * h1) + wt[14];
|
3702
|
+
culled = culled || z < 0;
|
3703
|
+
w = 1.0 / (wt[3] * w0 + wt[7] * h1 + wt[15]);
|
3704
|
+
vertexData[2] = w * ((wt[0] * w0) + (wt[4] * h1) + wt[12]);
|
3705
|
+
vertexData[3] = w * ((wt[1] * w0) + (wt[5] * h1) + wt[13]);
|
3706
|
+
z = (wt[2] * w0) + (wt[6] * h1) + wt[14];
|
3707
|
+
culled = culled || z < 0;
|
3708
|
+
w = 1.0 / (wt[3] * w0 + wt[7] * h0 + wt[15]);
|
3709
|
+
vertexData[4] = w * ((wt[0] * w0) + (wt[4] * h0) + wt[12]);
|
3710
|
+
vertexData[5] = w * ((wt[1] * w0) + (wt[5] * h0) + wt[13]);
|
3711
|
+
z = (wt[2] * w0) + (wt[6] * h0) + wt[14];
|
3712
|
+
culled = culled || z < 0;
|
3713
|
+
w = 1.0 / (wt[3] * w1 + wt[7] * h0 + wt[15]);
|
3714
|
+
vertexData[6] = w * ((wt[0] * w1) + (wt[4] * h0) + wt[12]);
|
3715
|
+
vertexData[7] = w * ((wt[1] * w1) + (wt[5] * h0) + wt[13]);
|
3716
|
+
z = (wt[2] * w1) + (wt[6] * h0) + wt[14];
|
3717
|
+
culled = culled || z < 0;
|
3718
|
+
this.trimmedCulledByFrustrum = culled;
|
3719
|
+
};
|
3720
|
+
Sprite3d.prototype._renderWebGL = function (renderer) {
|
3721
|
+
this.calculateVertices();
|
3722
|
+
if (this.culledByFrustrum) {
|
3723
|
+
return;
|
3724
|
+
}
|
3725
|
+
renderer.setObjectRenderer(renderer.plugins[this.pluginName]);
|
3726
|
+
renderer.plugins[this.pluginName].render(this);
|
3727
|
+
};
|
3728
|
+
Sprite3d.prototype.containsPoint = function (point) {
|
3729
|
+
if (this.culledByFrustrum) {
|
3730
|
+
return false;
|
3731
|
+
}
|
3732
|
+
return _super.prototype.containsPoint.call(this, point);
|
3733
|
+
};
|
3734
|
+
Object.defineProperty(Sprite3d.prototype, "worldTransform", {
|
3735
|
+
get: function () {
|
3736
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
3737
|
+
},
|
3738
|
+
enumerable: true,
|
3739
|
+
configurable: true
|
3740
|
+
});
|
3741
|
+
Sprite3d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
3742
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
3743
|
+
return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step);
|
3744
|
+
};
|
3745
|
+
Sprite3d.prototype.isFrontFace = function (forceUpdate) {
|
3746
|
+
return pixi_projection.container3dIsFrontFace.call(this, forceUpdate);
|
3747
|
+
};
|
3748
|
+
Sprite3d.prototype.getDepth = function (forceUpdate) {
|
3749
|
+
return pixi_projection.container3dGetDepth.call(this, forceUpdate);
|
3750
|
+
};
|
3751
|
+
Object.defineProperty(Sprite3d.prototype, "position3d", {
|
3752
|
+
get: function () {
|
3753
|
+
return this.proj.position;
|
3754
|
+
},
|
3755
|
+
set: function (value) {
|
3756
|
+
this.proj.position.copy(value);
|
3757
|
+
},
|
3758
|
+
enumerable: true,
|
3759
|
+
configurable: true
|
3760
|
+
});
|
3761
|
+
Object.defineProperty(Sprite3d.prototype, "scale3d", {
|
3762
|
+
get: function () {
|
3763
|
+
return this.proj.scale;
|
3764
|
+
},
|
3765
|
+
set: function (value) {
|
3766
|
+
this.proj.scale.copy(value);
|
3767
|
+
},
|
3768
|
+
enumerable: true,
|
3769
|
+
configurable: true
|
3770
|
+
});
|
3771
|
+
Object.defineProperty(Sprite3d.prototype, "euler", {
|
3772
|
+
get: function () {
|
3773
|
+
return this.proj.euler;
|
3774
|
+
},
|
3775
|
+
set: function (value) {
|
3776
|
+
this.proj.euler.copy(value);
|
3777
|
+
},
|
3778
|
+
enumerable: true,
|
3779
|
+
configurable: true
|
3780
|
+
});
|
3781
|
+
Object.defineProperty(Sprite3d.prototype, "pivot3d", {
|
3782
|
+
get: function () {
|
3783
|
+
return this.proj.pivot;
|
3784
|
+
},
|
3785
|
+
set: function (value) {
|
3786
|
+
this.proj.pivot.copy(value);
|
3787
|
+
},
|
3788
|
+
enumerable: true,
|
3789
|
+
configurable: true
|
3790
|
+
});
|
3791
|
+
return Sprite3d;
|
3792
|
+
}(PIXI.Sprite));
|
3793
|
+
pixi_projection.Sprite3d = Sprite3d;
|
3794
|
+
})(pixi_projection || (pixi_projection = {}));
|
3795
|
+
var pixi_projection;
|
3796
|
+
(function (pixi_projection) {
|
3797
|
+
var Text3d = (function (_super) {
|
3798
|
+
__extends(Text3d, _super);
|
3799
|
+
function Text3d(text, style, canvas) {
|
3800
|
+
var _this = _super.call(this, text, style, canvas) || this;
|
3801
|
+
_this.proj = new pixi_projection.Projection3d(_this.transform);
|
3802
|
+
_this.pluginName = 'sprite2d';
|
3803
|
+
_this.vertexData = new Float32Array(12);
|
3804
|
+
return _this;
|
3805
|
+
}
|
3806
|
+
Object.defineProperty(Text3d.prototype, "worldTransform", {
|
3807
|
+
get: function () {
|
3808
|
+
return this.proj.affine ? this.transform.worldTransform : this.proj.world;
|
3809
|
+
},
|
3810
|
+
enumerable: true,
|
3811
|
+
configurable: true
|
3812
|
+
});
|
3813
|
+
Text3d.prototype.toLocal = function (position, from, point, skipUpdate, step) {
|
3814
|
+
if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; }
|
3815
|
+
return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step);
|
3816
|
+
};
|
3817
|
+
Text3d.prototype.isFrontFace = function (forceUpdate) {
|
3818
|
+
return pixi_projection.container3dIsFrontFace.call(this, forceUpdate);
|
3819
|
+
};
|
3820
|
+
Text3d.prototype.getDepth = function (forceUpdate) {
|
3821
|
+
return pixi_projection.container3dGetDepth.call(this, forceUpdate);
|
3822
|
+
};
|
3823
|
+
Object.defineProperty(Text3d.prototype, "position3d", {
|
3824
|
+
get: function () {
|
3825
|
+
return this.proj.position;
|
3826
|
+
},
|
3827
|
+
set: function (value) {
|
3828
|
+
this.proj.position.copy(value);
|
3829
|
+
},
|
3830
|
+
enumerable: true,
|
3831
|
+
configurable: true
|
3832
|
+
});
|
3833
|
+
Object.defineProperty(Text3d.prototype, "scale3d", {
|
3834
|
+
get: function () {
|
3835
|
+
return this.proj.scale;
|
3836
|
+
},
|
3837
|
+
set: function (value) {
|
3838
|
+
this.proj.scale.copy(value);
|
3839
|
+
},
|
3840
|
+
enumerable: true,
|
3841
|
+
configurable: true
|
3842
|
+
});
|
3843
|
+
Object.defineProperty(Text3d.prototype, "euler", {
|
3844
|
+
get: function () {
|
3845
|
+
return this.proj.euler;
|
3846
|
+
},
|
3847
|
+
set: function (value) {
|
3848
|
+
this.proj.euler.copy(value);
|
3849
|
+
},
|
3850
|
+
enumerable: true,
|
3851
|
+
configurable: true
|
3852
|
+
});
|
3853
|
+
Object.defineProperty(Text3d.prototype, "pivot3d", {
|
3854
|
+
get: function () {
|
3855
|
+
return this.proj.pivot;
|
3856
|
+
},
|
3857
|
+
set: function (value) {
|
3858
|
+
this.proj.pivot.copy(value);
|
3859
|
+
},
|
3860
|
+
enumerable: true,
|
3861
|
+
configurable: true
|
3862
|
+
});
|
3863
|
+
return Text3d;
|
3864
|
+
}(PIXI.Text));
|
3865
|
+
pixi_projection.Text3d = Text3d;
|
3866
|
+
Text3d.prototype.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices;
|
3867
|
+
Text3d.prototype.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices;
|
3868
|
+
Text3d.prototype._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds;
|
3869
|
+
Text3d.prototype.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint;
|
3870
|
+
Text3d.prototype._renderWebGL = pixi_projection.Sprite3d.prototype._renderWebGL;
|
3871
|
+
})(pixi_projection || (pixi_projection = {}));
|
3872
|
+
var pixi_projection;
|
3873
|
+
(function (pixi_projection) {
|
3874
|
+
var containerProps = {
|
3875
|
+
worldTransform: {
|
3876
|
+
get: pixi_projection.container3dWorldTransform,
|
3877
|
+
enumerable: true,
|
3878
|
+
configurable: true
|
3879
|
+
},
|
3880
|
+
position3d: {
|
3881
|
+
get: function () { return this.proj.position; },
|
3882
|
+
set: function (value) { this.proj.position.copy(value); }
|
3883
|
+
},
|
3884
|
+
scale3d: {
|
3885
|
+
get: function () { return this.proj.scale; },
|
3886
|
+
set: function (value) { this.proj.scale.copy(value); }
|
3887
|
+
},
|
3888
|
+
pivot3d: {
|
3889
|
+
get: function () { return this.proj.pivot; },
|
3890
|
+
set: function (value) { this.proj.pivot.copy(value); }
|
3891
|
+
},
|
3892
|
+
euler: {
|
3893
|
+
get: function () { return this.proj.euler; },
|
3894
|
+
set: function (value) { this.proj.euler.copy(value); }
|
3895
|
+
}
|
3896
|
+
};
|
3897
|
+
function convertTo3d() {
|
3898
|
+
if (this.proj)
|
3899
|
+
return;
|
3900
|
+
this.proj = new pixi_projection.Projection3d(this.transform);
|
3901
|
+
this.toLocal = pixi_projection.Container3d.prototype.toLocal;
|
3902
|
+
this.isFrontFace = pixi_projection.Container3d.prototype.isFrontFace;
|
3903
|
+
this.getDepth = pixi_projection.Container3d.prototype.getDepth;
|
3904
|
+
Object.defineProperties(this, containerProps);
|
3905
|
+
}
|
3906
|
+
PIXI.Container.prototype.convertTo3d = convertTo3d;
|
3907
|
+
PIXI.Sprite.prototype.convertTo3d = function () {
|
3908
|
+
if (this.proj)
|
3909
|
+
return;
|
3910
|
+
this.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices;
|
3911
|
+
this.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices;
|
3912
|
+
this._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds;
|
3913
|
+
this.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint;
|
3914
|
+
this.pluginName = 'sprite2d';
|
3915
|
+
this.vertexData = new Float32Array(12);
|
3916
|
+
convertTo3d.call(this);
|
3917
|
+
};
|
3918
|
+
PIXI.mesh.Mesh.prototype.convertTo3d = function () {
|
3919
|
+
if (this.proj)
|
3920
|
+
return;
|
3921
|
+
this.pluginName = 'mesh2d';
|
3922
|
+
convertTo3d.call(this);
|
3923
|
+
};
|
3924
|
+
PIXI.Container.prototype.convertSubtreeTo3d = function () {
|
3925
|
+
this.convertTo3d();
|
3926
|
+
for (var i = 0; i < this.children.length; i++) {
|
3927
|
+
this.children[i].convertSubtreeTo3d();
|
3928
|
+
}
|
3929
|
+
};
|
3930
|
+
})(pixi_projection || (pixi_projection = {}));
|
3931
|
+
var pixi_projection;
|
3932
|
+
(function (pixi_projection) {
|
3933
|
+
var Spine2d = (function (_super) {
|
3934
|
+
__extends(Spine2d, _super);
|
3935
|
+
function Spine2d(spineData) {
|
3936
|
+
var _this = _super.call(this, spineData) || this;
|
3937
|
+
_this.convertTo2d();
|
3938
|
+
return _this;
|
3939
|
+
}
|
3940
|
+
Spine2d.prototype.newContainer = function () {
|
3941
|
+
return new pixi_projection.Container2d();
|
3942
|
+
};
|
3943
|
+
Spine2d.prototype.newSprite = function (tex) {
|
3944
|
+
return new pixi_projection.Sprite2d(tex);
|
3945
|
+
};
|
3946
|
+
Spine2d.prototype.newGraphics = function () {
|
3947
|
+
return new PIXI.Graphics();
|
3948
|
+
};
|
3949
|
+
Spine2d.prototype.newMesh = function (texture, vertices, uvs, indices, drawMode) {
|
3950
|
+
return new pixi_projection.Mesh2d(texture, vertices, uvs, indices, drawMode);
|
3951
|
+
};
|
3952
|
+
Spine2d.prototype.transformHack = function () {
|
3953
|
+
return 2;
|
3954
|
+
};
|
3955
|
+
return Spine2d;
|
3956
|
+
}(PIXI.spine.Spine));
|
3957
|
+
pixi_projection.Spine2d = Spine2d;
|
3958
|
+
})(pixi_projection || (pixi_projection = {}));
|
3959
|
+
var pixi_projection;
|
3960
|
+
(function (pixi_projection) {
|
3961
|
+
var Spine3d = (function (_super) {
|
3962
|
+
__extends(Spine3d, _super);
|
3963
|
+
function Spine3d(spineData) {
|
3964
|
+
var _this = _super.call(this, spineData) || this;
|
3965
|
+
_this.convertTo3d();
|
3966
|
+
return _this;
|
3967
|
+
}
|
3968
|
+
Spine3d.prototype.newContainer = function () {
|
3969
|
+
return new pixi_projection.Container3d();
|
3970
|
+
};
|
3971
|
+
Spine3d.prototype.newSprite = function (tex) {
|
3972
|
+
return new pixi_projection.Sprite3d(tex);
|
3973
|
+
};
|
3974
|
+
Spine3d.prototype.newGraphics = function () {
|
3975
|
+
return new PIXI.Graphics();
|
3976
|
+
};
|
3977
|
+
Spine3d.prototype.newMesh = function (texture, vertices, uvs, indices, drawMode) {
|
3978
|
+
return new pixi_projection.Mesh3d(texture, vertices, uvs, indices, drawMode);
|
3979
|
+
};
|
3980
|
+
Spine3d.prototype.transformHack = function () {
|
3981
|
+
return 3;
|
3982
|
+
};
|
3983
|
+
return Spine3d;
|
3984
|
+
}(PIXI.spine.Spine));
|
3985
|
+
pixi_projection.Spine3d = Spine3d;
|
3986
|
+
})(pixi_projection || (pixi_projection = {}));
|
3987
|
+
//# sourceMappingURL=pixi-projection-spine.js.map
|