regl-worldview
Advanced tools
Comparing version 0.1.5-rc3 to 0.1.5-rc4
{ | ||
"name": "regl-worldview", | ||
"version": "0.1.5-rc3", | ||
"version": "0.1.5-rc4", | ||
"description": "A reusable component for rendering 2D and 3D views using regl", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -13,4 +13,5 @@ // @flow | ||
import type { Arrow, GetChildrenForHitmap } from "../types"; | ||
import type { Arrow } from "../types"; | ||
import { pointToVec3, vec3ToPoint, orientationToVec4, vec4ToOrientation } from "../utils/commandUtils"; | ||
import { getChildrenForHitmapWithOriginalMarker } from "../utils/getChildrenForHitmapDefaults"; | ||
import type { CommonCommandProps } from "./Command"; | ||
@@ -27,22 +28,2 @@ import Cones from "./Cones"; | ||
const getChildrenForHitmapWithOriginalMarker: GetChildrenForHitmap = <T: any>( | ||
props: T, | ||
assignNextColors, | ||
excludedObjects | ||
) => { | ||
// This is almost identical to the default nonInstancedGetChildrenForHitmap, with changes marked. | ||
return props | ||
.map((prop) => { | ||
if (excludedObjects.some(({ object }) => object === prop)) { | ||
return null; | ||
} | ||
const hitmapProp = { ...prop }; | ||
// Change from original: pass the original marker as a callback object instead of this marker. | ||
const [hitmapColor] = assignNextColors({ type: "single", object: prop.originalMarker }); | ||
hitmapProp.color = hitmapColor; | ||
return hitmapProp; | ||
}) | ||
.filter(Boolean); | ||
}; | ||
function Arrows(props: Props) { | ||
@@ -131,2 +112,2 @@ const passedProps = omit(props, "children"); | ||
export default memo(Arrows); | ||
export default memo<Props>(Arrows); |
@@ -14,3 +14,3 @@ // @flow | ||
import { shouldConvert, pointToVec3 } from "../utils/commandUtils"; | ||
import { nonInstancedGetChildrenForHitmap } from "../utils/getChildrenForHitmapDefaults"; | ||
import { getChildrenForHitmapWithOriginalMarker } from "../utils/getChildrenForHitmapDefaults"; | ||
import Triangles from "./Triangles"; | ||
@@ -63,2 +63,3 @@ | ||
scale: DEFAULT_SCALE, | ||
originalMarker: poly, | ||
}; | ||
@@ -70,3 +71,3 @@ }); | ||
return ( | ||
<Triangles getChildrenForHitmap={nonInstancedGetChildrenForHitmap} {...rest}> | ||
<Triangles getChildrenForHitmap={getChildrenForHitmapWithOriginalMarker} {...rest}> | ||
{triangles} | ||
@@ -73,0 +74,0 @@ </Triangles> |
@@ -193,3 +193,3 @@ // @flow | ||
export type MouseEventObject = { | ||
object: ?BaseShape, | ||
object: BaseShape, | ||
instanceIndex: ?number, | ||
@@ -196,0 +196,0 @@ }; |
@@ -14,3 +14,4 @@ // @flow | ||
assignNextColors: AssignNextColorsFn, | ||
excludedObjects: MouseEventObject[] | ||
excludedObjects: MouseEventObject[], | ||
useOriginalMarkerProp: boolean = false | ||
): ?T { | ||
@@ -21,3 +22,6 @@ if (excludedObjects.some(({ object }) => object === prop)) { | ||
const hitmapProp = { ...prop }; | ||
const [hitmapColor] = assignNextColors({ type: "single", object: prop }); | ||
const [hitmapColor] = assignNextColors({ | ||
type: "single", | ||
object: useOriginalMarkerProp ? prop.originalMarker : prop, | ||
}); | ||
hitmapProp.color = hitmapColor; | ||
@@ -43,2 +47,17 @@ if (hitmapProp.colors && hitmapProp.points && hitmapProp.points.length) { | ||
// Almost identical to nonInstancedGetChildrenForHitmap, but instead the object passed to event callbacks is the object | ||
// at `prop.originalMarker`, not just `prop`. | ||
export const getChildrenForHitmapWithOriginalMarker = <T: any>( | ||
props: T, | ||
assignNextColors: AssignNextColorsFn, | ||
excludedObjects: MouseEventObject[] | ||
) => { | ||
if (Array.isArray(props)) { | ||
return props | ||
.map((prop) => nonInstancedGetChildrenForHitmapFromSingleProp(prop, assignNextColors, excludedObjects, true)) | ||
.filter(Boolean); | ||
} | ||
return nonInstancedGetChildrenForHitmapFromSingleProp(props, assignNextColors, excludedObjects, true); | ||
}; | ||
function instancedGetChildrenForHitmapFromSingleProp<T: any>( | ||
@@ -45,0 +64,0 @@ prop: T, |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
2563276
14905