diff --git a/dist/ThreeCanary.js b/dist/ThreeCanary.js
index cc916d3..ae52a07 100644
--- a/dist/ThreeCanary.js
+++ b/dist/ThreeCanary.js
@@ -113,7 +113,9 @@ function Points(_ref) {
key: i,
nodeId: i,
position: position,
- onNodeSelected: handleSelectedNode
+ onNodeSelected: handleSelectedNode,
+ dialogData: nodesData[selected],
+ onNodeClick: onNodeClick
});
})));
}
@@ -121,7 +123,9 @@ function Points(_ref) {
function Point(_ref2) {
var nodeId = _ref2.nodeId,
position = _ref2.position,
- onNodeSelected = _ref2.onNodeSelected;
+ dialogData = _ref2.dialogData,
+ onNodeSelected = _ref2.onNodeSelected,
+ onNodeClick = _ref2.onNodeClick;
var ref = (0, _react.useRef)();
var _useState3 = (0, _react.useState)(false),
@@ -166,7 +170,7 @@ function Point(_ref2) {
return setHover(false);
},
onClick: function onClick(e) {
- return onNodeSelected(nodeId);
+ return onNodeClick(dialogData.hash);
}
})));
}
@@ -196,13 +200,7 @@ function PointDialog(_ref3) {
emissive: brandPalette[0]
}), /*#__PURE__*/_react.default.createElement(_drei.Html, {
distanceFactor: 2
- }, /*#__PURE__*/_react.default.createElement(DialogContent, null, dialogData.img ? /*#__PURE__*/_react.default.createElement(DialogImage, {
- src: dialogData.img,
- alt: dialogData.name,
- onClick: handleNodeClick
- }) : null, dialogData.name ? /*#__PURE__*/_react.default.createElement(DialogTitle, {
- onClick: handleNodeClick
- }, dialogData.name) : null, dialogData.level ? /*#__PURE__*/_react.default.createElement(DialogLabel, null, dialogData.level) : null, dialogData.hash ? /*#__PURE__*/_react.default.createElement(DialogHash, null, formatHash(dialogData.hash)) : null)));
+ }, /*#__PURE__*/_react.default.createElement(DialogContent, null, dialogData.hash ? /*#__PURE__*/_react.default.createElement(DialogHash, null, dialogData.hash) : null)));
}
function Model(props) {
diff --git a/package-lock.json b/package-lock.json
index a37c068..0fabe71 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@kappasigmamu/canary-component",
- "version": "0.3.1",
+ "version": "0.3.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@kappasigmamu/canary-component",
- "version": "0.3.1",
+ "version": "0.3.3",
"license": "MIT",
"dependencies": {
"@babel/polyfill": "^7.12.1",
diff --git a/package.json b/package.json
index b89db36..100bf5f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@kappasigmamu/canary-component",
- "version": "0.3.2",
+ "version": "0.3.3",
"description": "React Component that renders the KappaSigmaMu Canary in 3D",
"keywords": [
"kusama",
diff --git a/src/lib/ThreeCanary.js b/src/lib/ThreeCanary.js
index 2de0e21..3c2015a 100644
--- a/src/lib/ThreeCanary.js
+++ b/src/lib/ThreeCanary.js
@@ -30,7 +30,7 @@ const formatHash = (str) => {
const sep = "..."
const strLen = str.length
const head = str.slice(0, numChars)
- const tail = str.slice(strLen-5, strLen)
+ const tail = str.slice(strLen - 5, strLen)
return head + sep + tail
}
@@ -41,7 +41,7 @@ function Points({ objectUrl, nodesData, onNodeClick }) {
// Or nodes.Scene.children[0].geometry.attributes.position
const positions = nodes.canary.geometry.attributes.position
-
+
const numPositions = positions.count
const numNodes = nodesData.length
const randomIndexes = useMemo(() => randomN(0, numPositions, numNodes), [numPositions, numNodes])
@@ -59,10 +59,10 @@ function Points({ objectUrl, nodesData, onNodeClick }) {
: null
}
-
+
{
selectedPositions.map((position, i) => (
-
+
))
}
@@ -70,7 +70,7 @@ function Points({ objectUrl, nodesData, onNodeClick }) {
)
}
-function Point({ nodeId, position, onNodeSelected }) {
+function Point({ nodeId, position, dialogData, onNodeSelected, onNodeClick }) {
const ref = useRef()
const [hovered, setHover] = useState(false)
const [active] = useState(false)
@@ -89,22 +89,22 @@ function Point({ nodeId, position, onNodeSelected }) {
if (hovered) {
ref.current.color.lerp(color.set(hovered ? brandPalette[0] : brandPalette[1]), hovered ? 1 : 0.1)
}
-
+
if (active) {
- ref.current.scale.x = ref.current.scale.y = ref.current.scale.z += Math.sin( t ) / 4
+ ref.current.scale.x = ref.current.scale.y = ref.current.scale.z += Math.sin(t) / 4
ref.current.color.lerp(color.set(active ? brandPalette[2] : brandPalette[1]), active ? 1 : 0.1)
}
})
return (
-
+
<>
(e.stopPropagation(), setHover(true), onNodeSelected(nodeId))}
+ onPointerOver={(e) => (e.stopPropagation(), setHover(true), onNodeSelected(nodeId))}
onPointerOut={() => setHover(false)}
- onClick={(e) => onNodeSelected(nodeId)}
- />
+ onClick={(e) => onNodeClick(dialogData.hash)}
+ />
>
)
@@ -122,38 +122,23 @@ function PointDialog({ position, dialogData, onNodeClick }) {
useFrame((state) => {
const t = state.clock.getElapsedTime()
- ref.current.position.copy(new THREE.Vector3(position[0]*scale, -position[2]*scale, position[1]*scale))
+ ref.current.position.copy(new THREE.Vector3(position[0] * scale, -position[2] * scale, position[1] * scale))
ref.current.scale.x = ref.current.scale.y = ref.current.scale.z = 0.05
- ref.current.position.y += Math.sin( t ) / 16
+ ref.current.position.y += Math.sin(t) / 16
})
return (
-
-
-
-
- { dialogData.img ?
- : null }
- { dialogData.name ?
-
- { dialogData.name }
- : null }
- { dialogData.level ?
-
- { dialogData.level }
- : null }
- { dialogData.hash ?
-
- { formatHash(dialogData.hash) }
- : null }
-
-
-
+
+
+
+
+ {dialogData.hash ?
+
+ {dialogData.hash}
+ : null}
+
+
+
)
}
@@ -179,17 +164,17 @@ function Lights() {
useFrame((state) => {
const t = state.clock.getElapsedTime()
- groupL.current.position.x = Math.sin( t ) / 2;
- groupL.current.position.y = Math.cos( t ) / 2;
- groupL.current.position.z = Math.cos( t ) / 2;
+ groupL.current.position.x = Math.sin(t) / 2;
+ groupL.current.position.y = Math.cos(t) / 2;
+ groupL.current.position.z = Math.cos(t) / 2;
- groupR.current.position.x = Math.cos( t ) / 2;
- groupR.current.position.y = Math.sin( t ) / 2;
- groupR.current.position.z = Math.sin( t ) / 2;
+ groupR.current.position.x = Math.cos(t) / 2;
+ groupR.current.position.y = Math.sin(t) / 2;
+ groupR.current.position.z = Math.sin(t) / 2;
- front.current.position.x = Math.sin( t ) / 2;
- front.current.position.y = Math.cos( t ) / 2;
- front.current.position.z = Math.sin( t ) / 2;
+ front.current.position.x = Math.sin(t) / 2;
+ front.current.position.y = Math.cos(t) / 2;
+ front.current.position.z = Math.sin(t) / 2;
})
return (
@@ -253,7 +238,7 @@ function Particles({ count }) {
<>
-
+
>
)
@@ -264,10 +249,10 @@ function ThreeCanary(props) {
return (