5
我使用Three.js創建了一個小遊戲,除了使用立方體的shome着色問題外,一切都進行得很順利。我基本上是通過將紋理立方體放下以形成迷宮來構建遊戲級別。問題是,當立方體彼此相鄰時,每個立方體都被遮蔽,看上去好像它是一個單獨的實體,而不是更大的牆的一部分。如何在Three.js中更改立方體陰影的方式?
這裏有一個例子,注意到一個單壁的假象丟失:
是否有不同的陰影技術,我應該用或者是有一個很好的特性在某處被設置爲改變這一陰影行爲?
這是我的立方體模型:
{
"metadata" :
{
"formatVersion" : 3,
"generatedBy" : "Blender 2.60 Exporter",
"vertices" : 8,
"faces" : 6,
"normals" : 8,
"colors" : 0,
"uvs" : 4,
"materials" : 1,
"morphTargets" : 0
},
"scale" : 1.000000,
"materials": [{
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "WallCube",
"colorAmbient" : [1.0, 1.0, 1.0],
"colorDiffuse" : [1.0, 1.0, 1.0],
"colorSpecular" : [0.15, 0.15, 0.15],
"mapDiffuse" : "../../textures/walls/stone/stone.png",
"mapDiffuseWrap" : ["repeat", "repeat"],
"mapNormal" : "../../textures/walls/stone/stone_normal.png",
"mapNormalFactor" : 1.0,
"shading" : "Lambert",
"specularCoef" : 25,
"transparency" : 1.0,
"vertexColors" : false
}],
"vertices": [50.000000,-50.000000,-50.000000,50.000000,-50.000000,50.000000,-50.000000,-50.000000,50.000000,-50.000000,-50.000000,-50.000000,50.000000,50.000000,-50.000000,50.000000,50.000000,50.0000050,-50.000000,50.000000,50.000000,-50.000000,50.000000,-50.000000],
"morphTargets": [],
"normals": [1.000000,-1.000000,-1.000000,1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,-1.000000,1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,1.000000,1.000000,1.000000,1.000000],
"colors": [],
"uvs": [[0.000000,1.000000,1.000000,1.000000,1.000000,0.000000,0.000000,0.000000]],
"faces": [43,0,1,2,3,0,0,1,2,3,0,1,2,3,43,4,7,6,5,0,0,1,2,3,4,5,6,7,43,0,4,5,1,0,1,2,3,0,0,4,7,1,43,1,5,6,2,0,1,2,3,0,1,7,6,2,43,2,6,7,3,0,1,2,3,0,2,6,5,3,43,4,0,3,7,0,3,0,1,2,4,0,3,5]
}
,這是我怎麼加載:
JSONLoader = new THREE.JSONLoader();
Light = new THREE.PointLight(0xFFFFFF);
Light.position = {x:0, y:75, z:350};
Meshes = [];
JSONLoader.load("../assets/models/cube.js", function(Geometry)
{
for (var MeshIndex = 0; MeshIndex <= 5; MeshIndex++)
{
Meshes[MeshIndex] = new THREE.Mesh(Geometry, new THREE.MeshFaceMaterial());
Meshes[MeshIndex].position.x = MeshIndex * 100;
Scene.add(Meshes[MeshIndex]);
}
});
Scene.add(Light);
任何想法如何讓立方體看起來像一個連續牆?