New segments can be added in the middle of a sketch (#1953)
* get branch up to where it was before * setup dots properly * only show extra handle on hover * use partical texture for plus button * fix regression * fix deleted line * fix sketch on face test * caluclate segment length in screen-space/in-pixels * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * side small segment handles on resize * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Make sure this works on setup and update of segments * Add to tangential arcs * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit5dc1adacae
. * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commitb8ceea179c
. * try and fix sketch on face in CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * more test fix * convert scaling to be based on pixels * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger ci * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit6287c943dd
. * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)" This reverts commit1baa3819db
. * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update src/clientSideScene/segments.ts Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * reduce line thickness * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * try putting init script back in --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Frank Noirot <frank@zoo.dev>
This commit is contained in:
@ -18,6 +18,8 @@ import {
|
||||
Intersection,
|
||||
Object3D,
|
||||
Object3DEventMap,
|
||||
TextureLoader,
|
||||
Texture,
|
||||
} from 'three'
|
||||
import { compareVec2Epsilon2 } from 'lang/std/sketch'
|
||||
import { useModelingContext } from 'hooks/useModelingContext'
|
||||
@ -54,6 +56,7 @@ export const ARROWHEAD = 'arrowhead'
|
||||
|
||||
export interface OnMouseEnterLeaveArgs {
|
||||
selected: Object3D<Object3DEventMap>
|
||||
dragSelected?: Object3D<Object3DEventMap>
|
||||
mouseEvent: MouseEvent
|
||||
}
|
||||
|
||||
@ -98,18 +101,25 @@ export class SceneInfra {
|
||||
isFovAnimationInProgress = false
|
||||
_baseUnit: BaseUnit = 'mm'
|
||||
_baseUnitMultiplier = 1
|
||||
extraSegmentTexture: Texture
|
||||
onDragStartCallback: (arg: OnDragCallbackArgs) => void = () => {}
|
||||
onDragEndCallback: (arg: OnDragCallbackArgs) => void = () => {}
|
||||
onDragCallback: (arg: OnDragCallbackArgs) => void = () => {}
|
||||
onMoveCallback: (arg: OnMoveCallbackArgs) => void = () => {}
|
||||
onClickCallback: (arg: OnClickCallbackArgs) => void = () => {}
|
||||
onMouseEnter: (arg: OnMouseEnterLeaveArgs) => void = () => {}
|
||||
onMouseLeave: (arg: OnMouseEnterLeaveArgs) => void = () => {}
|
||||
setCallbacks = (callbacks: {
|
||||
onDragStart?: (arg: OnDragCallbackArgs) => void
|
||||
onDragEnd?: (arg: OnDragCallbackArgs) => void
|
||||
onDrag?: (arg: OnDragCallbackArgs) => void
|
||||
onMove?: (arg: OnMoveCallbackArgs) => void
|
||||
onClick?: (arg: OnClickCallbackArgs) => void
|
||||
onMouseEnter?: (arg: OnMouseEnterLeaveArgs) => void
|
||||
onMouseLeave?: (arg: OnMouseEnterLeaveArgs) => void
|
||||
}) => {
|
||||
this.onDragStartCallback = callbacks.onDragStart || this.onDragStartCallback
|
||||
this.onDragEndCallback = callbacks.onDragEnd || this.onDragEndCallback
|
||||
this.onDragCallback = callbacks.onDrag || this.onDragCallback
|
||||
this.onMoveCallback = callbacks.onMove || this.onMoveCallback
|
||||
this.onClickCallback = callbacks.onClick || this.onClickCallback
|
||||
@ -128,6 +138,8 @@ export class SceneInfra {
|
||||
}
|
||||
resetMouseListeners = () => {
|
||||
this.setCallbacks({
|
||||
onDragStart: () => {},
|
||||
onDragEnd: () => {},
|
||||
onDrag: () => {},
|
||||
onMove: () => {},
|
||||
onClick: () => {},
|
||||
@ -210,6 +222,13 @@ export class SceneInfra {
|
||||
const light = new AmbientLight(0x505050) // soft white light
|
||||
this.scene.add(light)
|
||||
|
||||
const textureLoader = new TextureLoader()
|
||||
this.extraSegmentTexture = textureLoader.load(
|
||||
'/clientSideSceneAssets/extra-segment-texture.png'
|
||||
)
|
||||
this.extraSegmentTexture.anisotropy =
|
||||
this.renderer?.capabilities?.getMaxAnisotropy?.()
|
||||
|
||||
SceneInfra.instance = this
|
||||
}
|
||||
|
||||
@ -358,6 +377,7 @@ export class SceneInfra {
|
||||
this.hoveredObject = firstIntersectObject
|
||||
this.onMouseEnter({
|
||||
selected: this.hoveredObject,
|
||||
dragSelected: this.selected?.object,
|
||||
mouseEvent: mouseEvent,
|
||||
})
|
||||
}
|
||||
@ -365,6 +385,7 @@ export class SceneInfra {
|
||||
if (this.hoveredObject) {
|
||||
this.onMouseLeave({
|
||||
selected: this.hoveredObject,
|
||||
dragSelected: this.selected?.object,
|
||||
mouseEvent: mouseEvent,
|
||||
})
|
||||
this.hoveredObject = null
|
||||
@ -453,8 +474,16 @@ export class SceneInfra {
|
||||
|
||||
if (this.selected) {
|
||||
if (this.selected.hasBeenDragged) {
|
||||
// this is where we could fire a onDragEnd event
|
||||
// console.log('onDragEnd', this.selected)
|
||||
// TODO do the types properly here
|
||||
this.onDragEndCallback({
|
||||
intersectionPoint: {
|
||||
twoD: planeIntersectPoint?.twoD as any,
|
||||
threeD: planeIntersectPoint?.threeD as any,
|
||||
},
|
||||
intersects,
|
||||
mouseEvent,
|
||||
selected: this.selected as any,
|
||||
})
|
||||
} else if (planeIntersectPoint?.twoD && planeIntersectPoint?.threeD) {
|
||||
// fire onClick event as there was no drags
|
||||
this.onClickCallback({
|
||||
|
Reference in New Issue
Block a user