Chore: Simplified ISheet's signature

This commit is contained in:
Aria Minaei 2021-07-03 15:36:00 +02:00
parent d161703c20
commit 2a671b129d
11 changed files with 125 additions and 138 deletions

View file

@ -6,12 +6,10 @@ import {types as t} from '@theatre/core'
import type {UseDragOpts} from './useDrag'
import useDrag from './useDrag'
const boxObjectConfig = {
props: t.compound({
x: t.number(0),
y: t.number(0),
}),
}
const boxObjectConfig = t.compound({
x: t.number(0),
y: t.number(0),
})
const Box: React.FC<{
id: string

View file

@ -6,12 +6,10 @@ import type {IProject, ISheet, ISheetObject} from '@theatre/core'
import {types as t} from '@theatre/core'
import type {IScrub, IStudio} from '@theatre/studio'
const boxObjectConfig = {
props: t.compound({
x: t.number(0),
y: t.number(0),
}),
}
const boxObjectConfig = t.compound({
x: t.number(0),
y: t.number(0),
})
const Box: React.FC<{
id: string

View file

@ -6,25 +6,23 @@ import type {IProject, ISheet, ISheetObject} from '@theatre/core'
import {types as t} from '@theatre/core'
import type {IScrub, IStudio} from '@theatre/studio'
const boxObjectConfig = {
props: t.compound({
position: t.compound({
x: t.number(0),
y: t.number(0),
z: t.number(0),
}),
scale: t.compound({
x: t.number(0),
y: t.number(0),
z: t.number(0),
origin: t.compound({
x: t.number(0),
y: t.number(0),
}),
w: t.number(0),
}),
const boxObjectConfig = t.compound({
position: t.compound({
x: t.number(0),
y: t.number(0),
z: t.number(0),
}),
}
scale: t.compound({
x: t.number(0),
y: t.number(0),
z: t.number(0),
origin: t.compound({
x: t.number(0),
y: t.number(0),
}),
w: t.number(0),
}),
})
const Box: React.FC<{
id: string

View file

@ -13,15 +13,13 @@ import {types} from '@theatre/core'
import type {ITurtle} from './turtle'
import {drawTurtlePlan, makeTurtlePlan} from './turtle'
const objConfig = {
props: types.compound({
startingPoint: types.compound({
x: types.number(0.5, {min: 0, max: 1}),
y: types.number(0.5, {min: 0, max: 1}),
}),
scale: types.number(1, {min: 0.1}),
const objConfig = types.compound({
startingPoint: types.compound({
x: types.number(0.5, {min: 0, max: 1}),
y: types.number(0.5, {min: 0, max: 1}),
}),
}
scale: types.number(1, {min: 0.1}),
})
const TurtleRenderer: React.FC<{
sheet: ISheet

View file

@ -22,29 +22,25 @@ export type TransformControlsMode = 'translate' | 'rotate' | 'scale'
export type TransformControlsSpace = 'world' | 'local'
export type ViewportShading = 'wireframe' | 'flat' | 'solid' | 'rendered'
export const baseSheetObjectType = {
props: types.compound({
position: types.compound({
x: types.number(0),
y: types.number(0),
z: types.number(0),
}),
rotation: types.compound({
x: types.number(0),
y: types.number(0),
z: types.number(0),
}),
scale: types.compound({
x: types.number(1),
y: types.number(1),
z: types.number(1),
}),
export const baseSheetObjectType = types.compound({
position: types.compound({
x: types.number(0),
y: types.number(0),
z: types.number(0),
}),
}
rotation: types.compound({
x: types.number(0),
y: types.number(0),
z: types.number(0),
}),
scale: types.compound({
x: types.number(1),
y: types.number(1),
z: types.number(1),
}),
})
export type BaseSheetObjectType = ISheetObject<
typeof baseSheetObjectType['props']
>
export type BaseSheetObjectType = ISheetObject<typeof baseSheetObjectType>
export interface AbstractEditable<T extends EditableType> {
type: T
@ -137,7 +133,7 @@ export interface EditableState {
export type EditorStore = {
sheet: ISheet | null
editorObject: ISheetObject<typeof editorSheetObjectConfig['props']> | null
editorObject: ISheetObject<typeof editorSheetObjectConfig> | null
sheetObjects: {[uniqueName in string]?: BaseSheetObjectType}
scene: Scene | null
gl: WebGLRenderer | null
@ -157,7 +153,7 @@ export type EditorStore = {
allowImplicitInstancing: boolean,
editorCamera: ContainerProps['camera'],
sheet: ISheet,
editorObject: null | ISheetObject<typeof editorSheetObjectConfig['props']>,
editorObject: null | ISheetObject<typeof editorSheetObjectConfig>,
) => void
setOrbitControlsRef: (
@ -292,29 +288,27 @@ export type BindFunction = (options: {
sheet: ISheet
}) => (options: {gl: WebGLRenderer; scene: Scene}) => void
const editorSheetObjectConfig = {
props: types.compound({
isOpen: types.boolean(false),
showAxes: types.boolean(true),
showGrid: types.boolean(true),
showOverlayIcons: types.boolean(false),
referenceWindowSize: types.number(120, {min: 0, max: 800}),
transformControlsMode: types.stringLiteral<TransformControlsMode>(
'translate',
['translate', 'rotate', 'scale'],
),
transformControlsSpace: types.stringLiteral<TransformControlsSpace>(
'world',
['local', 'world'],
),
viewportShading: types.stringLiteral<ViewportShading>('rendered', [
'flat',
'rendered',
'solid',
'wireframe',
]),
}),
}
const editorSheetObjectConfig = types.compound({
isOpen: types.boolean(false),
showAxes: types.boolean(true),
showGrid: types.boolean(true),
showOverlayIcons: types.boolean(false),
referenceWindowSize: types.number(120, {min: 0, max: 800}),
transformControlsMode: types.stringLiteral<TransformControlsMode>(
'translate',
['translate', 'rotate', 'scale'],
),
transformControlsSpace: types.stringLiteral<TransformControlsSpace>('world', [
'local',
'world',
]),
viewportShading: types.stringLiteral<ViewportShading>('rendered', [
'flat',
'rendered',
'solid',
'wireframe',
]),
})
export const bindToCanvas: BindFunction = ({
allowImplicitInstancing = false,