Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create an empty entity #43

Open
jfa257 opened this issue Aug 27, 2019 · 0 comments
Open

How to create an empty entity #43

jfa257 opened this issue Aug 27, 2019 · 0 comments

Comments

@jfa257
Copy link

jfa257 commented Aug 27, 2019

Hi,

I would like to know the process or a suggestion on how to create an empty father entity. I'm creating a card game, and since I made an extra object to simulate shadows, I need a father container so I can animate it without having extensive loops/arrays animating in sync the cards and their shadows. I'm going to try create an entity without desc, but not hoping to succeed on this, so if you could spare some of your time to help, would be much appreciated!

Update:

I was able to create the empty entity, and add the childrens, but I have a bug: whenever I apply a rotation in any axis, the children rotate on their own pivots. Any Idea why this is happening?

a snippet of code of what I'm doing to rotate:
if(entitycardsarray[0] !== null){ entitycardsarray[0].onScene(function (){ entitycardsarray[0].translateZ(0.0001).rotateZ(-Math.PI*0.00000045); }); }
and then the way I create the card container and push childrens:

` function drawcard()
{
var empty = Phoria.Entity.create({
points: [ {x:0,y:0,z:0} ],
style : {
drawmode: "point",
shademode: "callback",
geometrysortmode: "none",
objectsortmode: "front" // force render on-top of everything else
}
});
var c = Phoria.Util.generateUnitCustomCube(1,0.001,2);
var d = Phoria.Util.generateUnitCustomCube(1,0.001,2);
// var c = Phoria.Util.generateUnitCustomCube(3,1,7);
var cube = Phoria.Entity.create({
points: c.points,
edges: c.edges,
polygons: c.polygons,
style: {
color: [255,255,255],
diffuse: 1.5,
specular: 16,
emit: -1,
texture: 0
}
});
var shadowcube = Phoria.Entity.create({
points: d.points,
edges: d.edges,
polygons: d.polygons,
style: {
color: [10,10,10],
drawmode: "solid",
shademode: "plain",
opacity: 0.4
}
});
shadowcube.translateY(-1);
shadowcube.translateX(0.4);
shadowcube.translateZ(-0.6);

cube.textures.push(cardmaps[0]);
cube.textures.push(cardmaps[1]);
cube.polygons[4].texture = 1;
cube.polygons[5].texture = 0;

empty.children.push(cube);
empty.children.push(shadowcube);

entitycardsarray.push(empty);
scene.graph.push(empty);
} `

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant