From 4516300ba5a602afd792010893f82bca591e9b01 Mon Sep 17 00:00:00 2001 From: Mikyo King Date: Tue, 1 Aug 2023 17:20:03 -0600 Subject: [PATCH 1/3] feat: scale points --- src/Points.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Points.tsx b/src/Points.tsx index 659ba5c..5dd1209 100644 --- a/src/Points.tsx +++ b/src/Points.tsx @@ -115,6 +115,13 @@ export function Points({ useFrame(() => { data.forEach(({ position }, id) => { tempObject.position.set(position[0], position[1], position[2] || 0); + if (pointProps.scale) { + tempObject.scale.set( + pointProps.scale, + pointProps.scale, + pointProps.scale + ); + } if (meshRef.current) { meshRef.current.setMatrixAt(id, tempObject.matrix); meshRef.current.instanceMatrix.needsUpdate = true; From 70fc07967ffee166c9b834e06b27db3e0513bfbc Mon Sep 17 00:00:00 2001 From: Mikyo King Date: Tue, 1 Aug 2023 17:21:28 -0600 Subject: [PATCH 2/3] Add stories --- stories/Scale.stories.tsx | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 stories/Scale.stories.tsx diff --git a/stories/Scale.stories.tsx b/stories/Scale.stories.tsx new file mode 100644 index 0000000..17c0c02 --- /dev/null +++ b/stories/Scale.stories.tsx @@ -0,0 +1,108 @@ +import React, { useState } from 'react'; +import { Meta, Story } from '@storybook/react'; +import { + ThreeDimensionalCanvas, + ThreeDimensionalCanvasProps, + ThreeDimensionalControls, + Points, +} from '../src'; +import { Container } from './components'; +import _data from './data/point-cloud-3d.json'; +import { interpolateSinebow } from 'd3-scale-chromatic'; + +const meta: Meta = { + title: 'Scale', + component: ThreeDimensionalCanvas, + argTypes: { + children: { + control: { + type: 'text', + }, + }, + }, + parameters: { + controls: { expanded: true }, + }, +}; + +export default meta; + +const data = _data.map((d, idx) => ({ + ...d, + metaData: { actualLabel: `${idx}` }, +})); + +const data2 = _data.map((d, idx) => ({ + ...d, + position: [d.position[0], d.position[1] + 1, d.position[2] + 1], + metaData: { actualLabel: `${idx}` }, +})); + +const actualLabelsArray = Array.from( + data.reduce((acc, d) => acc.add(d.metaData.actualLabel), new Set()) +); + +const labelCount = actualLabelsArray.length - 1; + +const actualLabelsColorMap: Map = actualLabelsArray.reduce( + (acc: Map, d, index) => { + acc[d as string] = index / labelCount; + return acc; + }, + new Map() as Map +); + +const colorByFn = (data) => { + const { actualLabel } = data.metaData; + return interpolateSinebow(actualLabelsColorMap[actualLabel]); +}; + +const Template: Story = (args) => { + const [scale, setScale] = useState(1); + return ( +
+ + + + + + + + + + + + + + setScale(parseFloat(e.target.value))} + /> +
+ ); +}; + +// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test +// https://storybook.js.org/docs/react/workflows/unit-testing +export const Default = Template.bind({}); + +Default.args = {}; From 35db8ec98feb59af0bde666272cec3c4b7227a3c Mon Sep 17 00:00:00 2001 From: Mikyo King Date: Tue, 1 Aug 2023 17:22:16 -0600 Subject: [PATCH 3/3] v3.0.3-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 332059d..14137b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@arizeai/point-cloud", - "version": "3.0.2", + "version": "3.0.3-0", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts",