Skip to content
Snippets Groups Projects
Select Git revision
  • 1eb2f42964c137e5fca24d7864c41990efa9dbb6
  • main default protected
  • state/ar_working
  • state/last_lisboa_sebi
  • feature/athens
  • feature/lisboa
  • evaluation-lisbon
  • feature/xr
  • feature/evaluation
  • 37-change-camera-controls
  • 4-fix-mouse-capture-for-2d-viewport-controls
  • feature/porto
  • feature/vr
  • feature/AR-marker
  • develop
  • feature/pages
  • feature/refactor-config
17 results

TF2.tsx

Blame
  • raytracing1.ts 983 B
    import Playground from "./playground";
    const pg = new Playground();
    
    const sphere = {
        position: [0, .5, -3],
        radius: 1.23
    }
    pg.visCamera(-1);
    pg.gridXZ()
    
    const o = [0, 0, 0]
    const co = ... // O - C
    
    const step = 1 / 8
    
    for (let yCoord = -1; yCoord <= 1; yCoord +=  step) {
    
        for (let xCoord = -1; xCoord <= 1; xCoord +=  step) {
    
            const v = [xCoord, yCoord, -1]
            const ov = ... // V - O
    
            pg.visVector(ov)
    
            const a = ... // <---- see equations above
            const b = ... // <---- see equations above
            const c = ... // <---- see equations above
     
            const discriminant = ... // <---- see equations above
    
            const t1 = (-b + Math.sqrt(discriminant)) / (2 * a)
            const t2 = (-b - Math.sqrt(discriminant)) / (2 * a)
            
            if (t1) {
                pg.visPoint(vecMultiplyScalar(t1, v),{color:"red"});
            }
    
            if (t2) {
                pg.visPoint(vecMultiplyScalar(t2, v),{color:"blue"});
            }
    
        }
    }