| private _firstHit: IObject3D | undefined | private _firstHit: IObject3D | undefined | ||||
| hoverEnabled = false | hoverEnabled = false | ||||
| /** | |||||
| * Time threshold for a pointer click event | |||||
| */ | |||||
| static PointerClickMaxTime = 200 | |||||
| /** | |||||
| * Distance threshold for a pointer click event | |||||
| */ | |||||
| static PointerClickMaxDistance = 0.1 // 1/20 of the canvas | |||||
| private _root: IObject3D | private _root: IObject3D | ||||
| private _camera: ICamera | private _camera: ICamera | ||||
| private _mouseDownTime: number | private _mouseDownTime: number | ||||
| private _mouseDownPos: Vector2 = new Vector2() | |||||
| private _mouseUpTime: number | private _mouseUpTime: number | ||||
| private _time: number | private _time: number | ||||
| public selectionCondition: (o: IObject3D) => boolean | public selectionCondition: (o: IObject3D) => boolean | ||||
| this.domElement.style.cursor = this.cursorStyles.down | this.domElement.style.cursor = this.cursorStyles.down | ||||
| this._mouseDownTime = this.time | this._mouseDownTime = this.time | ||||
| this._mouseDownPos.copy(this.mouse) | |||||
| return undefined | return undefined | ||||
| } | } | ||||
| this._mouseUpTime = this.time | this._mouseUpTime = this.time | ||||
| const delta = this.mouseDownDeltaTime | const delta = this.mouseDownDeltaTime | ||||
| if (delta < 200) { | |||||
| const dist = this._mouseDownPos.distanceTo(this.mouse) | |||||
| if (delta < ObjectPicker.PointerClickMaxTime && dist < ObjectPicker.PointerClickMaxDistance) { | |||||
| // click | // click | ||||
| this._onPointerClick(event) | this._onPointerClick(event) | ||||
| } | } |