-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.0 and above (currently 2.0.5)
Web browser and version
Google Chrome 139.0.7258.155 (Official Build) (64-bit)
Operating system
Windows
Steps to reproduce this
Steps:
- Run Example https://editor.p5js.org/Gabrz/sketches/8-h61uoAE and watch the lighted side of the cube (it moves).
- Switch to version 1.11.0 and run the sketch again. (light source stays fixed from right side)
Snippet:
let cam;
function setup() {
createCanvas(600, 400, WEBGL);
cam = createCamera()
}
function draw() {
background(30);
// Enable orbit control
orbitControl(2,2,2);
// Get camera position and target
let eye = createVector(cam.eyeX, cam.eyeY, cam.eyeZ);
let center = createVector(cam.centerX, cam.centerY, cam.centerZ);
let up = createVector(cam.upX, cam.upY, cam.upZ);
// Compute camera direction
let camDir = p5.Vector.sub(center, eye).normalize();
// Compute left vector (cross product of up and direction)
let camLeft = up.cross(camDir).normalize();
// Set directional light from the left of the camera
directionalLight(255, 255, 255, camLeft.x, camLeft.y, camLeft.z);
ambientLight(50);
// Draw a box
push();
//specularMaterial(250);
box(100);
pop();
}