From 37bad623e7304f485f87b3c7d8b555f33e471825 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Sat, 3 Feb 2024 20:09:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=87=20Adds=20touch=20for=20drag=20cont?= =?UTF-8?q?rols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/components/Model/sceneBuilder.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/components/Model/sceneBuilder.ts b/app/src/components/Model/sceneBuilder.ts index 4090670..eb8edc9 100644 --- a/app/src/components/Model/sceneBuilder.ts +++ b/app/src/components/Model/sceneBuilder.ts @@ -272,18 +272,14 @@ export default class SceneBuilder { this.setJointValue(joint.name, angle); updateAngle(joint.name, angle) }; - dragControls.onDragStart = () => { - this.controls.enabled = false; - }; - dragControls.onDragEnd = () => { - this.controls.enabled = true; - }; - dragControls.onHover = (joint:URDFMimicJoint) => { - this.highlightLinkGeometry(joint, false, highlightMaterial); - } - dragControls.onUnhover = (joint:URDFMimicJoint) => { - this.highlightLinkGeometry(joint, true, highlightMaterial); - } + dragControls.onDragStart = () => this.controls.enabled = false; + dragControls.onDragEnd = () => this.controls.enabled = true; + dragControls.onHover = (joint:URDFMimicJoint) => this.highlightLinkGeometry(joint, false, highlightMaterial); + dragControls.onUnhover = (joint:URDFMimicJoint) => this.highlightLinkGeometry(joint, true, highlightMaterial); + + this.renderer.domElement.addEventListener('touchstart', (data) => dragControls._mouseDown(data.touches[0])); + this.renderer.domElement.addEventListener('touchmove', (data) => dragControls._mouseMove(data.touches[0])) + this.renderer.domElement.addEventListener('touchup', (data) => dragControls._mouseUp(data.touches[0])); return this }