我有几个以json格式导入的3D对象已经被整理为单个对象。是否有任何方法可以点亮这个没有阴影的物体?我只是想让用户看到对象尽可能干净。 这是一些代码:
function initMesh(x, y, z) {
group = new THREE.Object3D();
var loader = new THREE.JSONLoader();
loader.load('vasi.js', function(geometry, materials) {
mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh.scale.x = x;
mesh.scale.y = y;
mesh.scale.z = z;
mesh.opacity=1;
var model = new THREE.Object3D();
model.add(mesh);
model.position.set(0,0,0);
//mesh.translation = THREE.GeometryUtils.center(geometry);
group.add(model);
});
loader.load('mikrespleures.js', function(geometry, materials) {
mesh1 = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh1.scale.x = x;
mesh1.scale.y = y;
mesh1.scale.z = z;
mesh1.opacity=1;
var model1 = new THREE.Object3D();
model1.add(mesh1);
model1.position.set(0,0,0);
//mesh1.translation = THREE.GeometryUtils.center(geometry);
group.add(model1);
});
loader.load('megalespleures.js', function(geometry, materials) {
mesh2 = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh2.scale.x = x;
mesh2.scale.y = y;
mesh2.scale.z = z;
mesh2.opacity=1;
var model2 = new THREE.Object3D();
model2.add(mesh2);
model2.position.set(0,0,0);
//mesh1.translation = THREE.GeometryUtils.center(geometry);
group.add(model2);
});
scene.add(group);}
function initLights() {
var light; // A light shining from the direction of the camera.
light = new THREE.DirectionalLight();
light.position.set(0,100,10);
group.castShadow = false;
group.receiveShadow = false;
scene.add(light);
}
谢谢!
答案 0 :(得分:1)
您可以将castShadow和receiveShadow标志设置为false。
function initMesh(x, y, z) {
group = new THREE.Object3D();
var loader = new THREE.JSONLoader();
loader.load('vasi.js', function(geometry, materials) {
mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh.scale.x = x;
mesh.scale.y = y;
mesh.scale.z = z;
mesh.opacity=1;
mesh.castShadow = false;
var model = new THREE.Object3D();
model.add(mesh);
model.position.set(0,0,0);
//mesh.translation = THREE.GeometryUtils.center(geometry);
group.add(model);
});
loader.load('mikrespleures.js', function(geometry, materials) {
mesh1 = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh1.scale.x = x;
mesh1.scale.y = y;
mesh1.scale.z = z;
mesh1.opacity=1;
mesh1.castShadow = false;
var model1 = new THREE.Object3D();
model1.add(mesh1);
model1.position.set(0,0,0);
//mesh1.translation = THREE.GeometryUtils.center(geometry);
group.add(model1);
});
loader.load('megalespleures.js', function(geometry, materials) {
mesh2 = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh2.scale.x = x;
mesh2.scale.y = y;
mesh2.scale.z = z;
mesh2.opacity=1;
mesh2.castShadow = false;
var model2 = new THREE.Object3D();
model2.add(mesh2);
model2.position.set(0,0,0);
//mesh1.translation = THREE.GeometryUtils.center(geometry);
group.add(model2);
});
scene.add(group);
}
function initLights() {
var light; // A light shining from the direction of the camera.
light = new THREE.DirectionalLight();
light.position.set(0,100,10);
group.castShadow = false;
group.receiveShadow = false;
scene.add(light);
}