gpt4 book ai didi

javascript - 如何将阴影转换到球体内部的物体上

转载 作者:行者123 更新时间:2023-11-28 07:20:07 25 4
gpt4 key购买 nike

我有一个位于球体内部的物体。我想在物体上使用光,并且阴影应该显示在球体上。我使用过 SpotLight 并检查过,但没有用。建议我如何设置灯光以及哪种类型的灯光最适合阴影。这是我的代码:

var group1 = new THREE.Group();
var obj = new THREE.Object3D();
var loader = new THREE.JSONLoader();

loader.load( 'obj.json', function ( geometry, materials ) {

var phongMaterials = materials.map( function ( material ) {
return new THREE.MeshPhongMaterial( {
color: new THREE.Color( material.color ),
shading: THREE.FlatShading,
shininess: 50,
//specular: 0xc00162
//wireframe: true
} )
} );

obj = new THREE.Mesh(
geometry,
new THREE.MeshFaceMaterial( phongMaterials )
);

obj.castShadow = true;

scene.add(obj);
group1.add( obj );

group1.position.set( 0, -180, -150 );
group1.rotation.set( 0, Math.PI/2, 0 );
group1.scale.set( 20, 20, 20 );

} );

scene.add( group1 );

//Sphere
group = new THREE.Group();
sphereMesh = new THREE.Group();

var material = new THREE.MeshPhongMaterial({
color : 0xffffff,
// emissive : 0xffffff,
transparent: true,
opacity : 0.5,

});

material.side = THREE.DoubleSide;

var icogeo = new THREE.IcosahedronGeometry(70,3);
icogeo.verticesNeedUpdate=true;
var sphere = new THREE.Mesh(icogeo, material);
sphere.receiveShadow = true;
group.add(sphere);
group.position.z=150;
scene.add(group);

最佳答案

好的,以下是您应该查看的 Material ,以帮助您准确地实现您想要做的事情,我的意思是准确地:

祝你好运

关于javascript - 如何将阴影转换到球体内部的物体上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30397656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com