Import a 3D Model and automatically assign and export animations
TypeScript
Allow for primary clicking to select bones to move
Scott Petrovic46a4dccfa34d
diff --git a/src/index.html b/src/index.htmlindex b70b4e5..cd010a9 100644--- a/src/index.html+++ b/src/index.html@@ -121,7 +121,7 @@<span id="skeleton-step-actions">- <p class="step-instructions">Right-click to select joints. Move bones into position.</p>+ <p class="step-instructions">Move bones into position.</p><p id="bone-selection-section"><span>Selected Bone: <span id="edit-selected-bone-label">None</span></span>diff --git a/src/lib/EventListeners.ts b/src/lib/EventListeners.tsindex 2791592..13a0d2b 100644--- a/src/lib/EventListeners.ts+++ b/src/lib/EventListeners.ts@@ -15,7 +15,7 @@ export class EventListeners {// edit skeleton step logic that deals with hovering over bonesif (this.bootstrap.process_step === ProcessStep.EditSkeleton) {- this.bootstrap.edit_skeleton_step.calculate_bone_hover_effect(event, this.bootstrap.camera)+ this.bootstrap.edit_skeleton_step.calculate_bone_hover_effect(event, this.bootstrap.camera, this.bootstrap.transform_controls_hover_distance)}})diff --git a/src/lib/processes/StepEditSkeleton.ts b/src/lib/processes/StepEditSkeleton.tsindex e235962..9da4060 100644--- a/src/lib/processes/StepEditSkeleton.ts+++ b/src/lib/processes/StepEditSkeleton.ts@@ -270,7 +270,7 @@ export class StepEditSkeleton extends EventTarget {* the event listener was originally setup in the EventListener.ts file* it is needed for the edit skeleton step, so I added logic here*/- public calculate_bone_hover_effect (event: MouseEvent, camera: Camera): void {+ public calculate_bone_hover_effect (event: MouseEvent, camera: Camera, hover_distance: number): void {// create a raycaster to detect the bone that is being hovered over// we will only have a hover effect if the mouse is close enough to the boneconst [closest_bone, closest_bone_index, closest_distance] =@@ -278,7 +278,7 @@ export class StepEditSkeleton extends EventTarget {// only do selection if we are close// the orbit controls also have panning with alt-click, so we don't want to interfere with that- if (closest_distance === null || closest_distance > 0.1) {+ if (closest_distance === null || closest_distance > hover_distance) {this.update_bone_hover_point_position(null)return}diff --git a/src/script.ts b/src/script.tsindex ef38908..9531e5f 100644--- a/src/script.ts+++ b/src/script.ts@@ -32,6 +32,7 @@ export class Bootstrap {public readonly transform_controls: TransformControls = new TransformControls(this.camera, this.renderer.domElement)public is_transform_controls_dragging: boolean = false+ public readonly transform_controls_hover_distance: number = 0.03 // distance to hover over bones to select them// has UI elements on the HTML page that we will reference/usepublic readonly ui = new UI()@@ -96,6 +97,9 @@ export class Bootstrap {this.scene.add(this.transform_controls.getHelper())+ // make transform control axis a bit smaller so they don't interfere with other points+ this.transform_controls.size = 1.0+// basic things in another group, to better isolate what we are working onthis.environment_container.name = 'Setup objects'this.environment_container.add(...Generators.create_default_lights())@@ -245,7 +249,8 @@ export class Bootstrap {// primary click is made for rotating around 3d sceneconst is_primary_button_click = mouse_event.button === 0- if (is_primary_button_click) { return }+ if (is_primary_button_click === false) { return }+if (this.edit_skeleton_step.skeleton()?.bones === undefined) { return }// when we are done with skinned mesh, we shouldn't be editing transforms@@ -268,7 +273,7 @@ export class Bootstrap {// only do selection if we are close// the orbit controls also have panning with alt-click, so we don't want to interfere with that- if (closest_distance === null || closest_distance > 0.1) {+ if (closest_distance === null || closest_distance > this.transform_controls_hover_distance) {return}