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,

View file

@ -13,9 +13,7 @@ import userReadableTypeOfValue from '@theatre/shared/utils/userReadableTypeOfVal
export type SheetObjectConfig<
Props extends PropTypeConfig_Compound<$IntentionalAny>,
> = {
props: Props
}
> = Props
export interface ISheet {
readonly type: 'Theatre_Sheet_PublicAPI'

View file

@ -1,4 +1,5 @@
{
"name": "theatre",
"private": true,
"version": "0.4.0-dev.3",
"workspaces": [

View file

@ -27,15 +27,17 @@ export async function setupTestSheet(sheetState: SheetState_Historic) {
ticker.tick()
await project.ready
const sheetPublicAPI = project.sheet('Sheet')
const objPublicAPI = sheetPublicAPI.object('obj', null, {
props: t.compound({
const objPublicAPI = sheetPublicAPI.object(
'obj',
null,
t.compound({
position: t.compound({
x: t.number(0),
y: t.number(1),
z: t.number(2),
}),
}),
})
)
const obj = privateAPI(objPublicAPI)

View file

@ -1,5 +1,5 @@
import type {PropTypeConfig_Compound} from '@theatre/core/propTypes'
import {isPropConfigComposite} from '@theatre/shared/src/propTypes/utils'
import {isPropConfigComposite} from '@theatre/shared/propTypes/utils'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import {theme} from '@theatre/studio/css'
import {voidFn} from '@theatre/shared/utils'

View file

@ -4,7 +4,7 @@ import type {
PropTypeConfig_AllPrimitives,
PropTypeConfig_Compound,
} from '@theatre/core/propTypes'
import {isPropConfigComposite} from '@theatre/shared/src/propTypes/utils'
import {isPropConfigComposite} from '@theatre/shared/propTypes/utils'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import type {IPropPathToTrackIdTree} from '@theatre/core/sheetObjects/SheetObjectTemplate'
import type Sheet from '@theatre/core/sheets/Sheet'

View file

@ -17672,9 +17672,53 @@ resolve@1.17.0:
languageName: node
linkType: hard
"theatre-7edd9a@workspace:theatre":
"theatre-example-dom@workspace:packages/example-dom":
version: 0.0.0-use.local
resolution: "theatre-7edd9a@workspace:theatre"
resolution: "theatre-example-dom@workspace:packages/example-dom"
dependencies:
"@theatre/core": "workspace:*"
"@theatre/studio": "workspace:*"
"@types/react": ^17.0.9
"@types/react-dom": ^17.0.6
parcel-bundler: ^1.12.5
react: ^17.0.2
react-dom: ^17.0.2
typescript: ^4.3.2
languageName: unknown
linkType: soft
"theatre-monorepo@workspace:.":
version: 0.0.0-use.local
resolution: "theatre-monorepo@workspace:."
dependencies:
"@babel/core": ^7.14.3
"@babel/plugin-proposal-class-properties": ^7.13.0
"@babel/plugin-proposal-nullish-coalescing-operator": ^7.14.2
"@babel/plugin-proposal-optional-chaining": ^7.14.2
"@babel/preset-env": ^7.14.4
"@babel/preset-react": ^7.13.13
"@babel/preset-typescript": ^7.13.0
"@typescript-eslint/eslint-plugin": ^4.26.0
"@typescript-eslint/parser": ^4.26.0
esbuild: ^0.12.5
esbuild-jest: ^0.5.0
eslint: ^7.27.0
eslint-plugin-jsx-a11y: ^6.4.1
eslint-plugin-react-hooks: ^4.2.0
eslint-plugin-unused-imports: ^1.1.1
husky: ^6.0.0
jest: ^27.0.3
lerna: ^4.0.0
lint-staged: ^11.0.0
node-gyp: ^8.1.0
prettier: ^2.3.1
typescript: ^4.3.2
languageName: unknown
linkType: soft
"theatre@workspace:theatre":
version: 0.0.0-use.local
resolution: "theatre@workspace:theatre"
dependencies:
"@babel/cli": ^7.14.3
"@babel/core": ^7.14.3
@ -17748,50 +17792,6 @@ resolve@1.17.0:
languageName: unknown
linkType: soft
"theatre-example-dom@workspace:packages/example-dom":
version: 0.0.0-use.local
resolution: "theatre-example-dom@workspace:packages/example-dom"
dependencies:
"@theatre/core": "workspace:*"
"@theatre/studio": "workspace:*"
"@types/react": ^17.0.9
"@types/react-dom": ^17.0.6
parcel-bundler: ^1.12.5
react: ^17.0.2
react-dom: ^17.0.2
typescript: ^4.3.2
languageName: unknown
linkType: soft
"theatre-monorepo@workspace:.":
version: 0.0.0-use.local
resolution: "theatre-monorepo@workspace:."
dependencies:
"@babel/core": ^7.14.3
"@babel/plugin-proposal-class-properties": ^7.13.0
"@babel/plugin-proposal-nullish-coalescing-operator": ^7.14.2
"@babel/plugin-proposal-optional-chaining": ^7.14.2
"@babel/preset-env": ^7.14.4
"@babel/preset-react": ^7.13.13
"@babel/preset-typescript": ^7.13.0
"@typescript-eslint/eslint-plugin": ^4.26.0
"@typescript-eslint/parser": ^4.26.0
esbuild: ^0.12.5
esbuild-jest: ^0.5.0
eslint: ^7.27.0
eslint-plugin-jsx-a11y: ^6.4.1
eslint-plugin-react-hooks: ^4.2.0
eslint-plugin-unused-imports: ^1.1.1
husky: ^6.0.0
jest: ^27.0.3
lerna: ^4.0.0
lint-staged: ^11.0.0
node-gyp: ^8.1.0
prettier: ^2.3.1
typescript: ^4.3.2
languageName: unknown
linkType: soft
"three-stdlib@npm:^2.0.1":
version: 2.0.5
resolution: "three-stdlib@npm:2.0.5"