Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js 投下阴影的问题_Three.js - Fatal编程技术网

Three.js 投下阴影的问题

Three.js 投下阴影的问题,three.js,Three.js,我希望我的桌板(桌子表面)和桌腿将它们的阴影投射到地板上 sceneSetup = () => { const width = this.el.clientWidth; const height = this.el.clientHeight; this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);

我希望我的桌板(桌子表面)和桌腿将它们的阴影投射到地板上

  sceneSetup = () => {
    const width = this.el.clientWidth;
    const height = this.el.clientHeight;
    this.scene = new THREE.Scene();
    this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
    this.camera.position.z = 5;
    this.controls = new OrbitControls(this.camera, this.el);
    this.renderer = new THREE.WebGLRenderer({antialias: true});
    this.renderer.shadowMap.enabled = true;
    this.renderer.setSize(width, height);
    this.el.appendChild(this.renderer.domElement);
  };

灯光

import * as THREE from "three";

export default ({ scene }) => {
    const lights = [];
    lights[0] = new THREE.PointLight(0xffffff, 1, 0);
    lights[0].position.set(0, 200, 0);
    lights[0].castShadow = true;
    scene.add(lights[0]);
  }
对象(网格)

渲染器

  sceneSetup = () => {
    const width = this.el.clientWidth;
    const height = this.el.clientHeight;
    this.scene = new THREE.Scene();
    this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
    this.camera.position.z = 5;
    this.controls = new OrbitControls(this.camera, this.el);
    this.renderer = new THREE.WebGLRenderer({antialias: true});
    this.renderer.shadowMap.enabled = true;
    this.renderer.setSize(width, height);
    this.el.appendChild(this.renderer.domElement);
  };

尝试类似于此代码部分()配置阴影,以确保阴影投射和接收对象位于阴影摄影机的平截头体中。您无处不在!谢谢你,穆根,我去看看。