three-render-objects
Advanced tools
Comparing version 1.23.0 to 1.24.0
@@ -247,7 +247,10 @@ 'use strict'; | ||
if (state.hoverDuringDrag || !state.isPointerDragging) { | ||
var intersects = this.intersectingObjects(state.pointerPos.x, state.pointerPos.y).map(function (_ref) { | ||
var object = _ref.object; | ||
return object; | ||
}).filter(state.hoverFilter).sort(state.hoverOrderComparator); | ||
topObject = intersects.length ? intersects[0] : null; | ||
var intersects = this.intersectingObjects(state.pointerPos.x, state.pointerPos.y).filter(function (d) { | ||
return state.hoverFilter(d.object); | ||
}).sort(function (a, b) { | ||
return state.hoverOrderComparator(a.object, b.object); | ||
}); | ||
var topIntersect = intersects.length ? intersects[0] : null; | ||
topObject = topIntersect ? topIntersect.object : null; | ||
state.intersectionPoint = topIntersect ? topIntersect.point : null; | ||
} | ||
@@ -343,6 +346,6 @@ | ||
var maxBoxSide = Math.max.apply(Math, _toConsumableArray(Object.entries(bbox).map(function (_ref2) { | ||
var _ref3 = _slicedToArray(_ref2, 2), | ||
coordType = _ref3[0], | ||
coords = _ref3[1]; | ||
var maxBoxSide = Math.max.apply(Math, _toConsumableArray(Object.entries(bbox).map(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
coordType = _ref2[0], | ||
coords = _ref2[1]; | ||
@@ -427,9 +430,9 @@ return Math.max.apply(Math, _toConsumableArray(coords.map(function (c) { | ||
}, | ||
init: function init(domNode, state, _ref5) { | ||
var _ref5$controlType = _ref5.controlType, | ||
controlType = _ref5$controlType === void 0 ? 'trackball' : _ref5$controlType, | ||
_ref5$rendererConfig = _ref5.rendererConfig, | ||
rendererConfig = _ref5$rendererConfig === void 0 ? {} : _ref5$rendererConfig, | ||
_ref5$waitForLoadComp = _ref5.waitForLoadComplete, | ||
waitForLoadComplete = _ref5$waitForLoadComp === void 0 ? true : _ref5$waitForLoadComp; | ||
init: function init(domNode, state, _ref4) { | ||
var _ref4$controlType = _ref4.controlType, | ||
controlType = _ref4$controlType === void 0 ? 'trackball' : _ref4$controlType, | ||
_ref4$rendererConfig = _ref4.rendererConfig, | ||
rendererConfig = _ref4$rendererConfig === void 0 ? {} : _ref4$rendererConfig, | ||
_ref4$waitForLoadComp = _ref4.waitForLoadComplete, | ||
waitForLoadComplete = _ref4$waitForLoadComp === void 0 ? true : _ref4$waitForLoadComp; | ||
// Wipe DOM | ||
@@ -494,3 +497,3 @@ domNode.innerHTML = ''; // Add relative container | ||
// left-click | ||
state.onClick(state.hoverObj || null, ev); // trigger background clicks with null | ||
state.onClick(state.hoverObj || null, ev, state.intersectionPoint); // trigger background clicks with null | ||
} | ||
@@ -500,3 +503,3 @@ | ||
// right-click | ||
state.onRightClick(state.hoverObj || null, ev); | ||
state.onRightClick(state.hoverObj || null, ev, state.intersectionPoint); | ||
} | ||
@@ -503,0 +506,0 @@ }, true); // use capture phase to prevent propagation blocking from controls (specifically for fly) |
@@ -243,7 +243,10 @@ import { WebGLRenderer, Scene, PerspectiveCamera, Raycaster, TextureLoader, Vector2, Vector3, Box3, Color, Mesh, SphereGeometry, MeshBasicMaterial, BackSide, EventDispatcher, MOUSE, Quaternion, Spherical, Clock } from 'three'; | ||
if (state.hoverDuringDrag || !state.isPointerDragging) { | ||
var intersects = this.intersectingObjects(state.pointerPos.x, state.pointerPos.y).map(function (_ref) { | ||
var object = _ref.object; | ||
return object; | ||
}).filter(state.hoverFilter).sort(state.hoverOrderComparator); | ||
topObject = intersects.length ? intersects[0] : null; | ||
var intersects = this.intersectingObjects(state.pointerPos.x, state.pointerPos.y).filter(function (d) { | ||
return state.hoverFilter(d.object); | ||
}).sort(function (a, b) { | ||
return state.hoverOrderComparator(a.object, b.object); | ||
}); | ||
var topIntersect = intersects.length ? intersects[0] : null; | ||
topObject = topIntersect ? topIntersect.object : null; | ||
state.intersectionPoint = topIntersect ? topIntersect.point : null; | ||
} | ||
@@ -339,6 +342,6 @@ | ||
var maxBoxSide = Math.max.apply(Math, _toConsumableArray(Object.entries(bbox).map(function (_ref2) { | ||
var _ref3 = _slicedToArray(_ref2, 2), | ||
coordType = _ref3[0], | ||
coords = _ref3[1]; | ||
var maxBoxSide = Math.max.apply(Math, _toConsumableArray(Object.entries(bbox).map(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
coordType = _ref2[0], | ||
coords = _ref2[1]; | ||
@@ -423,9 +426,9 @@ return Math.max.apply(Math, _toConsumableArray(coords.map(function (c) { | ||
}, | ||
init: function init(domNode, state, _ref5) { | ||
var _ref5$controlType = _ref5.controlType, | ||
controlType = _ref5$controlType === void 0 ? 'trackball' : _ref5$controlType, | ||
_ref5$rendererConfig = _ref5.rendererConfig, | ||
rendererConfig = _ref5$rendererConfig === void 0 ? {} : _ref5$rendererConfig, | ||
_ref5$waitForLoadComp = _ref5.waitForLoadComplete, | ||
waitForLoadComplete = _ref5$waitForLoadComp === void 0 ? true : _ref5$waitForLoadComp; | ||
init: function init(domNode, state, _ref4) { | ||
var _ref4$controlType = _ref4.controlType, | ||
controlType = _ref4$controlType === void 0 ? 'trackball' : _ref4$controlType, | ||
_ref4$rendererConfig = _ref4.rendererConfig, | ||
rendererConfig = _ref4$rendererConfig === void 0 ? {} : _ref4$rendererConfig, | ||
_ref4$waitForLoadComp = _ref4.waitForLoadComplete, | ||
waitForLoadComplete = _ref4$waitForLoadComp === void 0 ? true : _ref4$waitForLoadComp; | ||
// Wipe DOM | ||
@@ -490,3 +493,3 @@ domNode.innerHTML = ''; // Add relative container | ||
// left-click | ||
state.onClick(state.hoverObj || null, ev); // trigger background clicks with null | ||
state.onClick(state.hoverObj || null, ev, state.intersectionPoint); // trigger background clicks with null | ||
} | ||
@@ -496,3 +499,3 @@ | ||
// right-click | ||
state.onRightClick(state.hoverObj || null, ev); | ||
state.onRightClick(state.hoverObj || null, ev, state.intersectionPoint); | ||
} | ||
@@ -499,0 +502,0 @@ }, true); // use capture phase to prevent propagation blocking from controls (specifically for fly) |
{ | ||
"name": "three-render-objects", | ||
"version": "1.23.0", | ||
"version": "1.24.0", | ||
"description": "Easy way to render ThreeJS objects with built-in interaction defaults", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -85,4 +85,4 @@ three-render-objects | ||
| --- | --- | :--: | | ||
| <b>onClick</b>(<i>fn</i>) | Callback function for object clicks with left mouse button. The object (or `null` if there's no object under the mouse line of sight) and the event object are included as arguments `onClick(object, event)`. | - | | ||
| <b>onRightClick</b>(<i>fn</i>) | Callback function for object right-clicks. The object (or `null` if there's no object under the mouse line of sight) and the event object are included as arguments `onRightClick(object, event)`. | - | | ||
| <b>onClick</b>(<i>fn</i>) | Callback function for object clicks with left mouse button. The object (or `null` if there's no object under the mouse line of sight), the event object and the coordinates of the intersecting point in the object's surface are included as arguments `onClick(object, event, { x, y, z })`. | - | | ||
| <b>onRightClick</b>(<i>fn</i>) | Callback function for object right-clicks. The object (or `null` if there's no object under the mouse line of sight), the event object and the coordinates of the intersecting point in the object's surface are included as arguments `onRightClick(object, event, { x, y, z })`. | - | | ||
| <b>onHover</b>(<i>fn</i>) | Callback function for object mouse over events. The object (or `null` if there's no object under the mouse line of sight) is included as the first argument, and the previous hovered object (or `null`) as second argument: `onHover(obj, prevObj)`. | - | | ||
@@ -89,0 +89,0 @@ | <b>hoverOrderComparator</b>([<i>fn</i>]) | Getter/setter for the comparator function to use when hovering over multiple objects under the same line of sight. This function can be used to prioritize hovering some objects over others. | By default, hovering priority is based solely on camera proximity (closest object wins). | |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5146854
37560