Skip to content

Commit

Permalink
Format Everything (#8)
Browse files Browse the repository at this point in the history
* format everything

* fix format check script
  • Loading branch information
seveibar authored Jul 8, 2024
1 parent 756370a commit 8d8b216
Show file tree
Hide file tree
Showing 31 changed files with 270 additions and 71 deletions.
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"enabled": true,
"indentStyle": "space"
},
"files": {
"ignore": ["cosmos-export"]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
Expand Down
2 changes: 1 addition & 1 deletion examples/cone.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export default () => (
endAngle={Math.PI * 2}
/>
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/cuboid.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture>
<Cuboid size={[15, 10, 10]} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/custom-sphere.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<Sphere radius={10} segments={64} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/custom-torus.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export default () => (
startAngle={0}
/>
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/cylinder.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<Cylinder radius={10} height={20} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/ellipsoid.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<Ellipsoid radius={[15, 10, 10]} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/high-geodesic-sphere.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<GeodesicSphere radius={10} frequency={12} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/low-geodesic-sphere.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<GeodesicSphere radius={10} frequency={6} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/partial-cylindrical-elliptic.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export default () => (
endAngle={Math.PI / 2}
/>
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/rounded-cuboid.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture>
<RoundedCuboid size={[15, 10, 10]} roundRadius={1} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/rounded-cylinder.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default () => (
<JsCadFixture wireframe>
<RoundedCylinder radius={10} height={20} roundRadius={5} />
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/torus.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export default () => (
outerSegments={64}
/>
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion examples/twisted-cylindrical-elliptic.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export default () => (
endAngle={Math.PI * 2}
/>
</JsCadFixture>
)
)
2 changes: 1 addition & 1 deletion lib/components/jscad-fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function JsCadFixture({
75,
window.innerWidth / window.innerHeight,
0.1,
1000
1000,
)

// Add ambient light
Expand Down
2 changes: 1 addition & 1 deletion lib/convert-csg-to-three-geom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function convertCSGToThreeGeom(csg) {
const geo = new BufferGeometry()
geo.setAttribute(
"position",
new BufferAttribute(new Float32Array(vertices), 3)
new BufferAttribute(new Float32Array(vertices), 3),
)
geo.setIndex(indices)
if (csg.transforms) {
Expand Down
6 changes: 3 additions & 3 deletions lib/create-host-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function createHostConfig(jscad: JSCADModule) {
props: Props,

Check failure on line 39 in lib/create-host-config.ts

View workflow job for this annotation

GitHub Actions / type-check

Cannot find name 'Props'.
rootContainerInstance: any,
hostContext: any,
internalInstanceHandle: any
internalInstanceHandle: any,
) {
switch (type) {
case "cube":
Expand Down Expand Up @@ -125,7 +125,7 @@ export function createHostConfig(jscad: JSCADModule) {

removeChildFromContainer(
container: JSCADPrimitive[],
child: JSCADPrimitive
child: JSCADPrimitive,
) {
const index = container.indexOf(child)
if (index !== -1) container.splice(index, 1)
Expand All @@ -140,7 +140,7 @@ export function createHostConfig(jscad: JSCADModule) {
updatePayload: any,
type: string,
oldProps: Props,
newProps: Props
newProps: Props,
) {
// Re-create the instance with new props
return this.createInstance(type, newProps, instance, {}, null)
Expand Down
35 changes: 20 additions & 15 deletions lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import {
type CylinderProps,
type RoundedCylinderProps,
type CylinderEllipticProps,
type TorusProps
type TorusProps,
} from "./jscad-fns"

type Props =
CubeProps |
SphereProps |
GeodesicSphereProps |
CuboidProps |
RoundedCuboidProps |
EllipsoidProps |
CylinderProps |
RoundedCylinderProps |
CylinderEllipticProps |
TorusProps
| CubeProps
| SphereProps
| GeodesicSphereProps
| CuboidProps
| RoundedCuboidProps
| EllipsoidProps
| CylinderProps
| RoundedCylinderProps
| CylinderEllipticProps
| TorusProps

// Create a function that returns the reconciler and root creation function
function createJSCADRenderer(jscad: JSCADModule) {
Expand All @@ -51,11 +51,11 @@ function createJSCADRenderer(jscad: JSCADModule) {
null,
"",
(error) => console.error(error),
null
null,
)
return {
render(element: React.ReactElement) {
reconciler.updateContainer(element, root, null, () => { })
reconciler.updateContainer(element, root, null, () => {})
},
}
}
Expand All @@ -75,7 +75,12 @@ function Scene() {
<Ellipsoid radius={[5, 5, 5]} />
<Cylinder radius={5} height={10} />
<RoundedCylinder radius={5} height={10} roundRadius={2} />
<CylinderElliptic radius={5} height={10} startRadius={[2, 2]} endRadius={[3, 3]} />
<CylinderElliptic
radius={5}
height={10}
startRadius={[2, 2]}
endRadius={[3, 3]}
/>
<Torus radius={5} segments={32} tube={10} />
</>
)
Expand All @@ -95,5 +100,5 @@ export {
RoundedCylinder,
CylinderElliptic,
Torus,
Scene
Scene,
}
2 changes: 1 addition & 1 deletion lib/jscad-fns/cuboid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export type CuboidProps = {

export function Cuboid({ size }: CuboidProps) {
return <cuboid size={size} />
}
}
22 changes: 12 additions & 10 deletions lib/jscad-fns/cylinder-elliptic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ export function CylinderElliptic({
endRadius,
segments = 32,
startAngle = 0,
endAngle = Math.PI * 2
endAngle = Math.PI * 2,
}: CylinderEllipticProps) {
return <cylinderElliptic
height={height}
startRadius={startRadius}
endRadius={endRadius}
segments={segments}
startAngle={startAngle}
endAngle={endAngle}
/>
}
return (
<cylinderElliptic
height={height}
startRadius={startRadius}
endRadius={endRadius}
segments={segments}
startAngle={startAngle}
endAngle={endAngle}
/>
)
}
2 changes: 1 addition & 1 deletion lib/jscad-fns/cylinder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type CylinderProps = {

export function Cylinder({ radius, height }: CylinderProps) {
return <cylinder radius={radius} height={height} />
}
}
2 changes: 1 addition & 1 deletion lib/jscad-fns/ellipsoid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export type EllipsoidProps = {

export function Ellipsoid({ radius }: EllipsoidProps) {
return <ellipsoid radius={radius} />
}
}
2 changes: 1 addition & 1 deletion lib/jscad-fns/geodesic-sphere.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type GeodesicSphereProps = {

export function GeodesicSphere({ radius, frequency }: GeodesicSphereProps) {
return <geodesicSphere radius={radius} frequency={frequency} />
}
}
2 changes: 1 addition & 1 deletion lib/jscad-fns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export * from "./ellipsoid"
export * from "./cylinder"
export * from "./rounded-cylinder"
export * from "./cylinder-elliptic"
export * from "./torus"
export * from "./torus"
2 changes: 1 addition & 1 deletion lib/jscad-fns/rounded-cuboid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export type RoundedCuboidProps = {

export function RoundedCuboid({ size, roundRadius }: RoundedCuboidProps) {
return <roundedCuboid size={size} roundRadius={roundRadius} />
}
}
12 changes: 9 additions & 3 deletions lib/jscad-fns/rounded-cylinder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export type RoundedCylinderProps = {
export function RoundedCylinder({
radius,
height,
roundRadius
roundRadius,
}: RoundedCylinderProps) {
return <roundedCylinder radius={radius} height={height} roundRadius={roundRadius} />
}
return (
<roundedCylinder
radius={radius}
height={height}
roundRadius={roundRadius}
/>
)
}
22 changes: 12 additions & 10 deletions lib/jscad-fns/torus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export function Torus({
outerRotation,
startAngle = 0,
}: TorusProps) {
return <torus
innerRadius={innerRadius}
outerRadius={outerRadius}
innerSegments={innerSegments}
outerSegments={outerSegments}
innerRotation={innerRotation}
outerRotation={outerRotation}
startAngle={startAngle}
/>
}
return (
<torus
innerRadius={innerRadius}
outerRadius={outerRadius}
innerSegments={innerSegments}
outerSegments={outerSegments}
innerRotation={innerRotation}
outerRotation={outerRotation}
startAngle={startAngle}
/>
)
}
29 changes: 22 additions & 7 deletions lib/jscad-primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,46 @@ export interface JSCADModule {
size: number | [number, number, number]
}) => any
sphere: (options: {
radius: number, segments?: number
radius: number
segments?: number
}) => any
geodesicSphere: (options: {
radius: number, frequency: number
radius: number
frequency: number
}) => any
cuboid: (options: {
size: number | [number, number, number]
}) => any
roundedCuboid: (options: {
size: number | [number, number, number], roundRadius: number
size: number | [number, number, number]
roundRadius: number
}) => any
ellipsoid: (options: {
radius: [number, number, number]
}) => any
cylinder: (options: {
radius: number, height: number, startRadius?: number, endRadius?: number
radius: number
height: number
startRadius?: number
endRadius?: number
}) => any
roundedCylinder: (options: {
radius: number, height: number, roundRadius: number
radius: number
height: number
roundRadius: number
}) => any
cylinderElliptic: (options: {
radius: number, height: number, startRadius?: number[], endRadius?: number[], startAngle?: number, endAngle?: number
radius: number
height: number
startRadius?: number[]
endRadius?: number[]
startAngle?: number
endAngle?: number
}) => any
torus: (options: {
radius: number, tube: number, segments?: number
radius: number
tube: number
segments?: number
}) => any
}
booleans: {
Expand Down
Loading

0 comments on commit 8d8b216

Please sign in to comment.