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 type {UseDragOpts} from './useDrag'
import useDrag from './useDrag' import useDrag from './useDrag'
const boxObjectConfig = { const boxObjectConfig = t.compound({
props: t.compound({
x: t.number(0), x: t.number(0),
y: t.number(0), y: t.number(0),
}), })
}
const Box: React.FC<{ const Box: React.FC<{
id: string id: string

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
import type {PropTypeConfig_Compound} from '@theatre/core/propTypes' 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 type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import {theme} from '@theatre/studio/css' import {theme} from '@theatre/studio/css'
import {voidFn} from '@theatre/shared/utils' import {voidFn} from '@theatre/shared/utils'

View file

@ -4,7 +4,7 @@ import type {
PropTypeConfig_AllPrimitives, PropTypeConfig_AllPrimitives,
PropTypeConfig_Compound, PropTypeConfig_Compound,
} from '@theatre/core/propTypes' } 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 SheetObject from '@theatre/core/sheetObjects/SheetObject'
import type {IPropPathToTrackIdTree} from '@theatre/core/sheetObjects/SheetObjectTemplate' import type {IPropPathToTrackIdTree} from '@theatre/core/sheetObjects/SheetObjectTemplate'
import type Sheet from '@theatre/core/sheets/Sheet' import type Sheet from '@theatre/core/sheets/Sheet'

View file

@ -17672,9 +17672,53 @@ resolve@1.17.0:
languageName: node languageName: node
linkType: hard linkType: hard
"theatre-7edd9a@workspace:theatre": "theatre-example-dom@workspace:packages/example-dom":
version: 0.0.0-use.local 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: dependencies:
"@babel/cli": ^7.14.3 "@babel/cli": ^7.14.3
"@babel/core": ^7.14.3 "@babel/core": ^7.14.3
@ -17748,50 +17792,6 @@ resolve@1.17.0:
languageName: unknown languageName: unknown
linkType: soft 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": "three-stdlib@npm:^2.0.1":
version: 2.0.5 version: 2.0.5
resolution: "three-stdlib@npm:2.0.5" resolution: "three-stdlib@npm:2.0.5"