aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/bluebey-studio/src/rig.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/bluebey-studio/src/rig.js')
-rw-r--r--public/bluebey-studio/src/rig.js54
1 files changed, 4 insertions, 50 deletions
diff --git a/public/bluebey-studio/src/rig.js b/public/bluebey-studio/src/rig.js
index 2922dfa..e06c337 100644
--- a/public/bluebey-studio/src/rig.js
+++ b/public/bluebey-studio/src/rig.js
@@ -51,14 +51,6 @@ export class Rig {
this.controls.addEventListener('objectChange', () => {
if (this.selected) this.onChange?.(this.selected);
});
-
- this.raycaster = new THREE.Raycaster();
- this.pointer = new THREE.Vector2();
- this.pressAt = null;
- this.onPointerDown = this.handlePointerDown.bind(this);
- this.onPointerUp = this.handlePointerUp.bind(this);
- domElement.addEventListener('pointerdown', this.onPointerDown);
- domElement.addEventListener('pointerup', this.onPointerUp);
}
/* ------------------------------------------------------------ selection */
@@ -76,46 +68,10 @@ export class Rig {
if (!silent) this.onChange?.(this.selected);
}
- selectAt(event) {
- const rect = this.domElement.getBoundingClientRect();
- this.pointer.set(
- ((event.clientX - rect.left) / rect.width) * 2 - 1,
- -((event.clientY - rect.top) / rect.height) * 2 + 1,
- );
- this.raycaster.setFromCamera(this.pointer, this.controls.camera);
-
- const targets = this.pickTargets().filter((mesh) => mesh.visible);
- const hits = this.raycaster.intersectObjects(targets, false);
- if (!hits.length) return null;
-
- const point = hits[0].point;
- let best = null;
- let bestDistance = Infinity;
- const world = new THREE.Vector3();
- for (const entry of this.bones) {
- entry.bone.getWorldPosition(world);
- const distance = world.distanceToSquared(point);
- if (distance < bestDistance) {
- bestDistance = distance;
- best = entry.name;
- }
- }
- if (best) this.select(best);
- return best;
- }
-
- handlePointerDown(event) {
- // Remember where the press started so a drag never changes the selection.
- this.pressAt = { x: event.clientX, y: event.clientY, axis: this.controls.axis };
- }
-
- handlePointerUp(event) {
- const press = this.pressAt;
- this.pressAt = null;
- if (!press || press.axis) return; // pressed on the gizmo, not the model
- if (Math.hypot(event.clientX - press.x, event.clientY - press.y) > 4) return;
- this.selectAt(event);
- }
+ // Clicking the model no longer reaches for a bone: the mouse is for composing
+ // (see the drag handling in src/main.js), and bones are picked from the panel's
+ // bone list, which calls `select()` directly. So there is no pointer handler on
+ // the canvas here at all.
/* ----------------------------------------------------------------- pose */
@@ -185,8 +141,6 @@ export class Rig {
}
dispose() {
- this.domElement.removeEventListener('pointerdown', this.onPointerDown);
- this.domElement.removeEventListener('pointerup', this.onPointerUp);
this.controls.detach();
this.controls.dispose();
this.helper.removeFromParent();