WASD Arrows and Space keys X to toggle shadows Use Turbowarp for less lag: https://turbowarp.org/680590712?fps=60&hqpen&stuck
The first working implementation of 3D shadow volumes on Scratch. It is currently very laggy. Upon sharing this, I just found out an optimization that cuts a large bulk of computation*. The shadow algorithm uses the faces of the shadow volume casted by a triangle to partition all other triangles. Any triangle which has been partitioned by all faces of the shadow volume will be turned into a shadow triangle(triangular shadow volumes are frustums with 4 faces, 5 if there is a far plane). A shadow triangle can have lighting disabled for one light source, while still being lit by another light source. Using multiple light sources increases the lag, however. *A possible optimization is to not further partition a triangle if it is already shadowed. CREDITS: The improved BSP(binary space partitioning) algorithm uses a triangle cutting method by @Vadik1. The code itself is slightly based off of their code, except it is pretty much original. You can find and compare their code here: https://scratch.mit.edu/projects/277701036/editor/ The Bezier code for camera paths is (almost) directly taken from @gtoal's project: https://scratch.mit.edu/projects/131769048/ Quaternion look-at code from Unity forums. Compare with @ggenije's code: https://scratch.mit.edu/projects/470670022/ Much of the collision detection-response code comes from: https://wickedengine.net/2020/04/26/capsule-collision-detection/ Quaternion swing-twist decomposition code and derivation come from: http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition/index.htm Song is "Wait" by C418