Skip to content
Snippets Groups Projects
Select Git revision
  • f31b7176fbead69bafc84e2f2c985e8b1798dd2f
  • main default protected
  • rewrite
  • simulation-old
4 results

Example.ts

Blame
  • Example.ts 1.68 KiB
    import * as THREE from "three" ;
    import { PipelineData } from "../core/Pipeline";
    import { DebugHelper, Line1d, Line2d, Point2d, Point3d, Mesh } from "../core/Shapes";
    
    class Example extends PipelineData {
        public constructor() { super(); }
    
        data(): void {
            const pointsA = [];
            pointsA.push( new THREE.Vector3( 2, 0, 0 ) );
            pointsA.push( new THREE.Vector3( 0, -2, 0 ) );
            pointsA.push( new THREE.Vector3( -2, 0, 0 ) );
            
            const pointsB = [];
            pointsB.push( new THREE.Vector3( -2, 0, 0 ) );
            pointsB.push( new THREE.Vector3( 0, 2, 0 ) );
            pointsB.push( new THREE.Vector3( 2, 0, 0 ) );
            
            const point2d = new Point2d(.1, 32, new THREE.Color(0xffffff));
            const point3d = new Point3d(.1, 32, new THREE.Color(0xffffff));
            const line1d = new Line1d(pointsA, new THREE.Color(0xffffff));
            const line2d = new Line2d(pointsB, .001, new THREE.Color(0xffffff));
            const mesh = new Mesh("../assets/suzanne.obj", new THREE.Color(0xffffff));
            
            this.addShape(point2d, true, true);
            this.addShape(point3d, true, true);
            this.addShape(line1d, true, true); // gives a waring
            this.addShape(line2d, true, false);
            this.addShape(mesh, true, true);
    
            const debugHelper = new DebugHelper();
            this.observers.push(debugHelper);
            
            debugHelper.add(point2d);
            debugHelper.add(point3d);
            debugHelper.add(line1d);
            debugHelper.add(line2d);
            debugHelper.add(mesh);
            
            debugHelper.debug.forEach(object => {
                this.scene.add(object);
            });
        }
    }
    
    export { Example };