Closed jonlepage closed 6 years ago
ok a add i little hack to ytour plugin spine, see
if(slot.attachment && slot.attachment.name.indexOf("_n")>-1){
/* function Spine(spineData) {
var _this = _super.call(this) || this;
if (!spineData) {
throw new Error('The spineData param is required.');
}
if ((typeof spineData) === "string") {
throw new Error('spineData param cant be string. Please use spine.Spine.fromAtlas("YOUR_RESOURCE_NAME") from now on.');
}
_this.spineData = spineData;
_this.skeleton = new pixi_spine.core.Skeleton(spineData);
_this.skeleton.updateWorldTransform();
_this.stateData = new pixi_spine.core.AnimationStateData(spineData);
_this.state = new pixi_spine.core.AnimationState(_this.stateData);
_this.slotContainers = [];
_this.tempClipContainers = [];
for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) {
var slot = _this.skeleton.slots[i];
var attachment = slot.attachment;
var slotContainer = _this.newContainer();
*/
_this.slotContainers.push(slotContainer);
// check if the name have '_n', if yes it a normal, else a diffuse
if(slot.attachment && slot.attachment.name.indexOf("_n")>-1){
slotContainer.parentGroup = PIXI.lights.normalGroup;
}else{
slotContainer.parentGroup = PIXI.lights.diffuseGroup;
}
I find it pretty easy to duplicate a slot and inject a normal. Ideally it would be to prepare the photoshop file so that it includes all the '_n' names. It's a little longer to update a file that was not have normal at the base.
I will definitely wait for you to offer a more intelligent code I discussed it with dev from codeandweb, they tell me they will add new meta for detect more easy normal map with a atlas in next update.
a guy tell me a nice idea, attache a skin to say the current spine have a normal map. I need look this .
Edit: ok solved, i add this to your spine.js for now. I am going to wait for a more professional suggestion from you. For the moment it works well, what is important for allow me progress. The idea is simply to add a skin named "normal_n" when you work in SPINE2D sofware, that tell to your spine.js to add special extra parentgroup to slots and slots with "_n". I dont know about performance on this hack, but it make the workflow very easy. what do you think about this?
var haveNormal = !!spineData.findSkin("normal_n") || false; // is have skin named Normal_n
for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) {
var slot = _this.skeleton.slots[i];
var attachment = slot.attachment;
var slotContainer = _this.newContainer();
_this.slotContainers.push(slotContainer);
if(haveNormal){
if(slot.attachment && slot.attachment.name.indexOf("_n")>-1){
slotContainer.parentGroup = PIXI.lights.normalGroup;
slotContainer.isNormal = true; //allow easy debug
}else{
slotContainer.parentGroup = PIXI.lights.diffuseGroup;
}
};
Hi ivan I have a small crash experimenting with pixi light and the layer system. I do not know if these my group system would cause this? I separated the process in 2 steps for easy debug.
Step1, the loader will inject resource in a global variable. at this step are all fine.
step2 i initialise my layers system (original) and after inject light feature in the stage. the stage "
this
" are initialise before in other module. stagestep2 look at end on // PIXI LIGHT TEST IMPLEMENTATION
at the line
this.addChild(new PIXI.lights.AmbientLight(null, 0.4));
i get a errortexLayer.getRenderTexture is not a function
if i remove this line, i can see all the element normal seem loaded.
did you know what i'm doing wrong in my context ? i think it where and how i add light with new PIXI.display.Group? thank