mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added swapMeshes method to swap textures of 2 meshes
This commit is contained in:
parent
1db8de34df
commit
ec7ce459cb
3 changed files with 25 additions and 2 deletions
|
|
@ -21,7 +21,8 @@ function (Nc, Exception, Layer) {
|
||||||
Nc.on(Nc.ns.client.view.mesh.update, this.updateMesh, this),
|
Nc.on(Nc.ns.client.view.mesh.update, this.updateMesh, this),
|
||||||
Nc.on(Nc.ns.client.view.mesh.addFilter, this.addFilter, this),
|
Nc.on(Nc.ns.client.view.mesh.addFilter, this.addFilter, this),
|
||||||
Nc.on(Nc.ns.client.view.mesh.removeFilter, this.removeFilter, this),
|
Nc.on(Nc.ns.client.view.mesh.removeFilter, this.removeFilter, this),
|
||||||
Nc.on(Nc.ns.client.view.mesh.swapMeshIndexes, this.swapMeshIndexes, this)
|
Nc.on(Nc.ns.client.view.mesh.swapMeshIndexes, this.swapMeshIndexes, this),
|
||||||
|
Nc.on(Nc.ns.client.view.mesh.swapMeshes, this.swapMeshes, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,6 +164,11 @@ function (Nc, Exception, Layer) {
|
||||||
this.delegate.apply(this, arguments);
|
this.delegate.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LayerManager.prototype.swapMeshes = function() {
|
||||||
|
Array.prototype.splice.call(arguments, 0, 0, 'swapMeshes')
|
||||||
|
this.delegate.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
LayerManager.prototype.destroy = function() {
|
LayerManager.prototype.destroy = function() {
|
||||||
for (var i = 0; i < this.ncTokens.length; i++) {
|
for (var i = 0; i < this.ncTokens.length; i++) {
|
||||||
Nc.off(this.ncTokens[i]);
|
Nc.off(this.ncTokens[i]);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,22 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter, Nc) {
|
||||||
this.container.setChildIndex(meshB, indexA);
|
this.container.setChildIndex(meshB, indexA);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Layer.prototype.swapMeshes = function(meshA, meshB) {
|
||||||
|
var textureA = meshA.texture;
|
||||||
|
var textureB = meshB.texture;
|
||||||
|
|
||||||
|
meshA.setTexture(textureB);
|
||||||
|
meshA.onTextureUpdate();
|
||||||
|
meshA.scale.x = 1;
|
||||||
|
meshA.scale.y = 1;
|
||||||
|
|
||||||
|
meshB.setTexture(textureA);
|
||||||
|
meshB.onTextureUpdate();
|
||||||
|
meshB.scale.x = 1;
|
||||||
|
meshB.scale.y = 1;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
Layer.prototype.createMesh = function (texturePath, callback, options) {
|
Layer.prototype.createMesh = function (texturePath, callback, options) {
|
||||||
|
|
||||||
var texture = (options && options.fromFrame)
|
var texture = (options && options.fromFrame)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ function (Exception) {
|
||||||
update: null,
|
update: null,
|
||||||
addFilter: null,
|
addFilter: null,
|
||||||
removeFilter: null,
|
removeFilter: null,
|
||||||
swapMeshIndexes: null
|
swapMeshIndexes: null,
|
||||||
|
swapMeshes: null
|
||||||
},
|
},
|
||||||
animatedMesh: {
|
animatedMesh: {
|
||||||
create: null
|
create: null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue