I have a "2D" scene (Z pointing up) with a plane geometry as the game arena set like this:
var arenaMesh = new THREE.Mesh(
new THREE.PlaneGeometry(SceneWidth, SceneHeight),
new THREE.MeshLambertMaterial({
map: arenaTexture,
emissive: 0xffffff
}));
arenaMesh.position.x = SceneWidth / 2;
arenaMesh.position.y = SceneHeight / 2;
arenaMesh.position.z = 0;
arenaMesh.receiveShadow = true;
The game object is set like this (a really flat box):
var size = 20;
var bodyMesh = new THREE.Mesh(
new THREE.BoxGeometry(size, size, 0.01),
new THREE.MeshLambertMaterial({
map: bodyTexture,
alphaTest: 0.65,
emissive: 0xeeeeee
}));
bodyMesh.position.x = x0;
bodyMesh.position.y = y0;
bodyMesh.position.z = 5.0;
bodyMesh.castShadow = true;
I'm using BoxGeometry here due to some shadow problems I had before.
Now, the problem is that this works perfectly fine on my desktop (FF and Chrome): my fake 2D game object is rendered and it casts a shadow on the game arena. However, on Nexus 7 I can see only the shadow of the object! After some debugging, I noticed that If I set the z-position of the game object to a much bigger value, like z=15.0 it gets rendered. Unfortunately this is not acceptable, because then the object seems like it's flying. Lowering the game arena plane to e.g. z=-15.0 has the same effect. What the heck could cause this? I seems like the precision is somehow completely lost there. Why is the shadow still there correctly?