Skip to content
Snippets Groups Projects
Unverified Commit dc2e6dad authored by Jamie Temple's avatar Jamie Temple
Browse files

feat: interface update to add shapes comfortable

parent 7c045bae
No related branches found
No related tags found
1 merge request!1feat: base project
import * as THREE from 'three';
import { SpinningCube } from "./spinningCube"; import { SpinningCube } from "./spinningCube";
import { PipelineData } from "../core/Pipeline"; import { PipelineData } from "../core/Pipeline";
...@@ -8,11 +7,7 @@ class Demo extends PipelineData { ...@@ -8,11 +7,7 @@ class Demo extends PipelineData {
data(): void { data(): void {
const spinningCube = new SpinningCube(); const spinningCube = new SpinningCube();
this.scene.add(spinningCube.object3d); this.scene.add(spinningCube.object3d);
this.observers.push(spinningCube); this.addShape(spinningCube, true, false);
const light = new THREE.PointLight(0xffffff, 10, 100);
light.position.set(10, 0, 10);
this.scene.add(light);
} }
} }
......
...@@ -22,37 +22,24 @@ class Example extends PipelineData { ...@@ -22,37 +22,24 @@ class Example extends PipelineData {
const line2d = new Line2d(pointsB, .001, 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)); 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(); const debugHelper = new DebugHelper();
this.observers.push(debugHelper);
debugHelper.add(point2d); debugHelper.add(point2d);
debugHelper.add(point3d); debugHelper.add(point3d);
debugHelper.add(line1d); debugHelper.add(line1d);
debugHelper.add(line2d); debugHelper.add(line2d);
debugHelper.add(mesh); debugHelper.add(mesh);
this.scene.add(point2d.object3d);
this.scene.add(point3d.object3d);
this.scene.add(line1d.object3d);
this.scene.add(line2d.object3d);
this.scene.add(mesh.object3d);
debugHelper.debug.forEach(object => { debugHelper.debug.forEach(object => {
this.scene.add(object); this.scene.add(object);
}); });
this.observers.push(point2d);
this.observers.push(point3d);
this.observers.push(line1d);
this.observers.push(line2d);
this.observers.push(mesh);
this.observers.push(debugHelper);
this.draggables.push(point2d.object3d);
this.draggables.push(point3d.object3d);
this.draggables.push(mesh.object3d);
// will give a warning
this.draggables.push(line1d.object3d);
} }
} }
......
import * as THREE from 'three';
import { PipelineData } from "../core/Pipeline"; import { PipelineData } from "../core/Pipeline";
import { Point2d } from "../core/Shapes";
class BezierDemo extends PipelineData { class BezierDemo extends PipelineData {
public constructor() { super(); } public constructor() { super(); }
data(): void { data(): void {
/* INIT DATA HERE */ const point = new Point2d(.1, 36, new THREE.Color(0x00ff00));
this.addShape(point, true, true);
} }
} }
......
...@@ -2,6 +2,7 @@ import * as THREE from "three"; ...@@ -2,6 +2,7 @@ import * as THREE from "three";
import { DragControls } from "three/examples/jsm/controls/DragControls"; import { DragControls } from "three/examples/jsm/controls/DragControls";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
import { Shape } from "./Shapes";
interface PipelineObserver { interface PipelineObserver {
/** /**
...@@ -26,6 +27,16 @@ abstract class PipelineData { ...@@ -26,6 +27,16 @@ abstract class PipelineData {
this.data(); this.data();
} }
protected addShape(shape: Shape, observer: boolean = true, draggable: boolean = false) {
this.scene.add(shape.object3d);
if (observer) {
this.observers.push(shape);
}
if (draggable) {
this.draggables.push(shape.object3d);
}
}
/** /**
* @brief Should define a scenario with observers, draggables and scene. * @brief Should define a scenario with observers, draggables and scene.
* It initializes the scene and adds the draggables to the scene. * It initializes the scene and adds the draggables to the scene.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment