-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag and drop ability on viewer #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Table should not be displayed when loading
- We should use a # instead of a query param ?
- when we drag we should stay on the surface
- Nice to have but may be done a another pull-request (Bonus) save the lines added to the url ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove all spheres when clearing all - when adding the first and not the second one, it does not clear all spheres
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test url is not working ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parveshneedhoo Can we check if we can move the controls to another class
@@ -28,11 +28,11 @@ | |||
<tbody id="measurements"></tbody> | |||
</table> | |||
</div> | |||
<div id="loading"> | |||
<div id="loading" style="display: none;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use inline styling?
import { Measurements } from "./measurements"; | ||
|
||
export class DragControlHandler { | ||
private control: DragControls; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private control: DragControls; | |
private controls: DragControls; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behavior is good for me, I did not check all the code.
new THREE.BufferGeometry().setFromPoints([sphere1.position, sphere2.position]), | ||
new THREE.LineBasicMaterial({ color }) | ||
), | ||
color, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color, | |
this.generatedColor, |
window.addEventListener("unload", this.cleanup.bind(this)); | ||
container.addEventListener("click", this.onMouseClick.bind(this), false); | ||
container.addEventListener("mousedown", this.onMouseDown.bind(this), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if better to use Arrow funcctions here. Can be done in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should be handle all the events from loader and measurement in Drag Control Handler?
- Loader -> Measurement -> DragControlHandler : I think we handle the classes like and for example DragControlHandler should not have loader as a global variable
I will merge it like this. The comments can be handled in the next PR.
Reviewed with @parveshneedhoo
renderer: THREE.WebGLRenderer, | ||
private loader: Loader, | ||
private onDrag: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>) => void, | ||
private onDragEnd: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>, event: any) => void, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private onDragEnd: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>, event: any) => void, | |
private onDragEnd: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>, event: Event) => void, |
private loader: Loader, | ||
private onDrag: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>) => void, | ||
private onDragEnd: (object: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>, event: any) => void, | ||
measurements: Measurements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
measurements: Measurements | |
measurements: Measurements |
Move above privates
window.addEventListener('mousedown', this.onMouseDown); | ||
this.loader.lockRotationAndClick(); | ||
|
||
measurement.lastIntersectedPosition = event.object.position.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use callback in measurement
|
||
private handleDragEnd(event: THREE.Event, measurement: Measurements) { | ||
const onMouseUp = (mouseEvent: MouseEvent) => { | ||
measurement.updateMouse(mouseEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
measurement.updateMouse(mouseEvent); | |
measurement.updateMouse(mouseEvent); |
use measurement in measurement
@@ -54,11 +56,45 @@ export class Loader { | |||
|
|||
container.appendChild(this.renderer.domElement); | |||
|
|||
this.measurement = new Measurements(this.scene); | |||
this.measurement = new Measurements(this.scene, this.camera, this.renderer, this.group, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.measurement = new Measurements(this.scene, this.camera, this.renderer, this.group, this); | |
this.measurement = new Measurements(this.scene, this.camera, this.renderer, this.group); |
Handle all events in drag-control-handler
sphere2, | ||
line: new THREE.Line( | ||
new THREE.BufferGeometry().setFromPoints([sphere1.position, sphere2.position]), | ||
new THREE.LineBasicMaterial({ color }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new THREE.LineBasicMaterial({ color }) | |
new THREE.LineBasicMaterial({ color: this.generatedColor }) |
this.spherePairs = []; | ||
this.currentSpheres = []; | ||
this.generatedColor = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplication should we move that to a new function
Right now, on the 3D-viewer measurement, we can place two spheres to measure the distance between two points. In this PR, we will add the ability to drag the sphere once it is placed.