我似乎无法在Three.js场景中使用阴影

时间:2019-08-02 12:38:32

标签: three.js shadow gltf

我想在场景中添加阴影,但是阴影没有出现或出现毛刺/不正确。

我试图使其与AmbientLight,PointLight,DirectionalLight一起使用,但它们似乎都不起作用。

我将灯光设置为投射阴影,并设置场景中的所有网格物体以投射和接收阴影。

我的渲染器

java.lang.ClassNotFoundException: Failed to find data source: s3-sqs. Please find packages at http://spark.apache.org/third-party-projects.html
  at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:635)
  at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:159)
  ... 53 elided
Caused by: java.lang.ClassNotFoundException: s3-sqs.DefaultSource
  at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:62)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23$$anonfun$apply$15.apply(DataSource.scala:618)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23$$anonfun$apply$15.apply(DataSource.scala:618)
  at scala.util.Try$.apply(Try.scala:192)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23.apply(DataSource.scala:618)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23.apply(DataSource.scala:618)
  at scala.util.Try.orElse(Try.scala:84)
  at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:618)
  ... 54 more

var renderer,
        scene,
        camera;

    //RENDERER
    renderer = new THREE.WebGLRenderer({ 
      antialias: true
    });
    renderer.setClearColor("#e5e5e5");
    renderer.setPixelRatio(window.devicePixelRatio);
    renderer.setSize(window.innerWidth, window.innerHeight);

    renderer.shadowMap.enabled = true;
    renderer.shadowMap.type = THREE.BasicShadowMap; 

    document.body.appendChild(renderer.domElement);

我如何加载对象并将其设置为投射和接收阴影

    //LIGHTS
    var directionalLight = new THREE.DirectionalLight( 0xffffff );
    directionalLight.position.set( 150, 50, 100 );


    var d = 5;
    directionalLight.castShadow = true;
    directionalLight.shadow.camera.left = - d;
    directionalLight.shadow.camera.right = d;
    directionalLight.shadow.camera.top = d;
    directionalLight.shadow.camera.bottom = - d;    

    directionalLight.shadow.camera.near = 1;
    directionalLight.shadow.camera.far = 20;
    scene.add( directionalLight );

    var light2 = new THREE.PointLight(0xffffff, 0.5);
    light2.position.set(0,50,50);
    light2.castShadow = true;
    scene.add(light2);

在使用不同的灯光时,阴影始终显示出类似毛刺的状态或根本不显示。 整个代码位于ramonhoffman.nl/three上,因此您可以查看我正在使用的代码。

感谢您的时间!

0 个答案:

没有答案