Skip to content

Instantly share code, notes, and snippets.

@dosterz97
Last active June 27, 2022 20:21
Show Gist options
  • Save dosterz97/fbfffb2131dc31a5ab7808ffb988ec99 to your computer and use it in GitHub Desktop.
Save dosterz97/fbfffb2131dc31a5ab7808ffb988ec99 to your computer and use it in GitHub Desktop.
Camera, Controls, and Scene
async componentDidMount() {
const mainView = this.mainViewRef.current this.renderer = new THREE.WebGLRenderer({ antialias: true })
this.renderer.setSize(window.innerWidth, window.innerHeight - navigationBarHeight)
this.renderer.outputEncoding = THREE.sRGBEncoding
this.renderer.toneMapping = THREE.ACESFilmicToneMapping mainView.appendChild(this.renderer.domElement) this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / (window.innerHeight - navigationBarHeight), 0.1, 1000)
this.camera.position.set(0, 0, 3)
this.controls = new OrbitControls(this.camera, this.renderer.domElement)// We will use the lighting from the background instead of creating our own
const background = await this.loadBackground(backgroundUrl, this.renderer)
this.scene = new THREE.Scene()
this.scene.environment = background
this.scene.background = background
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment