three-render-objects
Advanced tools
Comparing version 1.19.0 to 1.20.0
@@ -156,2 +156,7 @@ 'use strict'; | ||
}; | ||
var DRAG_DURATION_THRESHOLD = 150; // ms | ||
var DRAG_DISTANCE_SQUARE_THRESHOLD = 25; | ||
var DRAG_ROTATION_SQUARE_THRESHOLD = 0.001; | ||
var threeRenderObjects = Kapsule({ | ||
@@ -212,2 +217,6 @@ props: { | ||
}, | ||
clickAfterDrag: { | ||
"default": false, | ||
triggerUpdate: false | ||
}, | ||
onHover: { | ||
@@ -511,3 +520,6 @@ "default": function _default() {}, | ||
state.controls.addEventListener('start', function () { | ||
return state.controlsEngaged = true; | ||
state.controlsEngaged = true; | ||
state._cameraPositionBeforeMove = state.camera.position.clone(); | ||
state._cameraRotationBeforeMove = state.camera.rotation.toVector3(); | ||
state._cameraMoveStartTime = +new Date(); | ||
}); | ||
@@ -517,3 +529,3 @@ state.controls.addEventListener('change', function () { | ||
state.controlsDragging = true; | ||
state.ignoreOneClick = true; | ||
!state.clickAfterDrag && !state.ignoreOneClick && +new Date() - state._cameraMoveStartTime > DRAG_DURATION_THRESHOLD && (state.camera.position.distanceToSquared(state._cameraPositionBeforeMove) > DRAG_DISTANCE_SQUARE_THRESHOLD || state.camera.rotation.toVector3().distanceToSquared(state._cameraRotationBeforeMove) > DRAG_ROTATION_SQUARE_THRESHOLD) && (state.ignoreOneClick = true); | ||
} | ||
@@ -520,0 +532,0 @@ }); |
@@ -66,2 +66,4 @@ import { WebGLRendererParameters, Object3D, WebGLRenderer, Scene, Camera } from 'three'; | ||
hoverDuringDrag(enabled: boolean): ChainableInstance; | ||
clickAfterDrag(): boolean; | ||
clickAfterDrag(enabled: boolean): ChainableInstance; | ||
@@ -68,0 +70,0 @@ // Utility |
@@ -152,2 +152,7 @@ import { WebGLRenderer, Scene, PerspectiveCamera, Raycaster, TextureLoader, Vector2, Vector3, Box3, Color, Mesh, SphereGeometry, MeshBasicMaterial, BackSide, EventDispatcher, MOUSE, Quaternion, Spherical, Clock } from 'three'; | ||
}; | ||
var DRAG_DURATION_THRESHOLD = 150; // ms | ||
var DRAG_DISTANCE_SQUARE_THRESHOLD = 25; | ||
var DRAG_ROTATION_SQUARE_THRESHOLD = 0.001; | ||
var threeRenderObjects = Kapsule({ | ||
@@ -208,2 +213,6 @@ props: { | ||
}, | ||
clickAfterDrag: { | ||
"default": false, | ||
triggerUpdate: false | ||
}, | ||
onHover: { | ||
@@ -507,3 +516,6 @@ "default": function _default() {}, | ||
state.controls.addEventListener('start', function () { | ||
return state.controlsEngaged = true; | ||
state.controlsEngaged = true; | ||
state._cameraPositionBeforeMove = state.camera.position.clone(); | ||
state._cameraRotationBeforeMove = state.camera.rotation.toVector3(); | ||
state._cameraMoveStartTime = +new Date(); | ||
}); | ||
@@ -513,3 +525,3 @@ state.controls.addEventListener('change', function () { | ||
state.controlsDragging = true; | ||
state.ignoreOneClick = true; | ||
!state.clickAfterDrag && !state.ignoreOneClick && +new Date() - state._cameraMoveStartTime > DRAG_DURATION_THRESHOLD && (state.camera.position.distanceToSquared(state._cameraPositionBeforeMove) > DRAG_DISTANCE_SQUARE_THRESHOLD || state.camera.rotation.toVector3().distanceToSquared(state._cameraRotationBeforeMove) > DRAG_ROTATION_SQUARE_THRESHOLD) && (state.ignoreOneClick = true); | ||
} | ||
@@ -516,0 +528,0 @@ }); |
{ | ||
"name": "three-render-objects", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "Easy way to render ThreeJS objects with built-in interaction defaults", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -93,2 +93,3 @@ three-render-objects | ||
| <b>hoverDuringDrag([<i>boolean</i>]) | Getter/setter for whether to trigger hover events while using the controls via pointer dragging.| `false` | | ||
| <b>clickAfterDrag([<i>boolean</i>]) | Getter/setter for whether to trigger a click event after dragging using the controls.| `false` | | ||
@@ -95,0 +96,0 @@ ### Utility |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
5144339
37517
108