Riaz_1
October 21, 2023, 12:49pm
1
First time coding with three.js. following this tut https://youtu.be/_OwJV2xL8M8 .
Im at 13:30. but my sphere just comes out like this. I also had to change my renderer bg color to even see it.
JS.
import * as THREE from 'three';
const scene = new THREE.Scene();
//create sphere
const geo = new THREE.SphereGeometry(3, 64, 64)
const mat = new THREE.MeshStandardMaterial({ color: "#00ff83" })
const sphere = new THREE.Mesh(geo, mat)
scene.add(sphere)
const light = new THREE.PointLight('#FFFFFF', 1, 100)
light.position.set(0, 10, 10)
scene.add(light)
const camera = new THREE.PerspectiveCamera(45, 800 / 600)
camera.position.z = 10
scene.add(camera)
const canvas = document.querySelector('.webgl');
const renderer = new THREE.WebGLRenderer({ canvas })
renderer.setSize(800, 600)
renderer.setClearColor(0xEEEEEE);
renderer.render(scene, camera)```
html
<!doctype html>
Vite App
```
Try with a stronger light:
const light = new THREE.PointLight('#FFFFFF', 100, 100)
1 Like
Riaz_1
October 22, 2023, 6:30pm
3
Thank you! it worked! if its ok could u explain this to me a little :), or direct me to a place that would
Most likely the tutorial is using an old release of Three.js, where lights and their parameters were designed to use “nice” numbers. Since release 155 lights and their properties are closer to physical lights. You can find more details here:
The upcoming release r155 will contain a major change in context of lighting. The legacy lighting mode will be disabled by default which affects all light intensities and how point and spot lights decay.
What does that mean for me?
The release changes the default of WebGLRenderer.useLegacyLights from true to false and also deprecates the property. Meaning it will be eventually removed from the engine with r165.
Setting WebGLRenderer.useLegacyLights to false is one important prerequisite for a…
1 Like