@threlte/theatre 3.0.7 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/project/Project.svelte +34 -13
- package/dist/project/Project.svelte.d.ts +4 -2
- package/dist/sequence/Sequence.svelte +102 -71
- package/dist/sequence/Sequence.svelte.d.ts +5 -5
- package/dist/sequence/SequenceController.d.ts +2 -2
- package/dist/sequence/SequenceController.js +1 -1
- package/dist/sequence/useSequence.d.ts +1 -1
- package/dist/sheet/Sheet.svelte +34 -16
- package/dist/sheet/Sheet.svelte.d.ts +5 -3
- package/dist/sheet/types.d.ts +1 -1
- package/dist/sheetObject/SheetObject.svelte +108 -75
- package/dist/sheetObject/SheetObject.svelte.d.ts +11 -4
- package/dist/sheetObject/declare/Declare.svelte +23 -14
- package/dist/sheetObject/declare/Declare.svelte.d.ts +11 -4
- package/dist/sheetObject/sync/Sync.svelte +122 -85
- package/dist/sheetObject/sync/Sync.svelte.d.ts +15 -4
- package/dist/sheetObject/sync/types.d.ts +1 -1
- package/dist/sheetObject/sync/utils/getInitialValue.js +2 -2
- package/dist/sheetObject/sync/utils/isComplexProp.d.ts +1 -1
- package/dist/sheetObject/sync/utils/isStringProp.d.ts +1 -1
- package/dist/sheetObject/sync/utils/parsePropLabel.d.ts +1 -1
- package/dist/sheetObject/transfomers/createTransformer.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/color.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/color.js +2 -2
- package/dist/sheetObject/transfomers/defaults/degrees.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/degrees.js +2 -2
- package/dist/sheetObject/transfomers/defaults/euler.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/euler.js +2 -2
- package/dist/sheetObject/transfomers/defaults/generic.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/generic.js +3 -3
- package/dist/sheetObject/transfomers/defaults/normalized.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/normalized.js +2 -2
- package/dist/sheetObject/transfomers/defaults/side.d.ts +1 -1
- package/dist/sheetObject/transfomers/defaults/side.js +2 -2
- package/dist/sheetObject/transfomers/getDefaultTransformer.d.ts +1 -1
- package/dist/sheetObject/transfomers/getDefaultTransformer.js +6 -6
- package/dist/sheetObject/transform/Transform.svelte +145 -120
- package/dist/sheetObject/transform/Transform.svelte.d.ts +11 -4
- package/dist/studio/InnerStudio.svelte +31 -19
- package/dist/studio/InnerStudio.svelte.d.ts +5 -3
- package/dist/studio/Studio.svelte +12 -3
- package/dist/studio/Studio.svelte.d.ts +4 -2
- package/dist/studio/useStudio.js +1 -1
- package/dist/theatre/Theatre.svelte +15 -2
- package/dist/theatre/Theatre.svelte.d.ts +4 -2
- package/package.json +11 -12
|
@@ -6,106 +6,139 @@
|
|
|
6
6
|
<script
|
|
7
7
|
lang="ts"
|
|
8
8
|
generics="Props extends UnknownShorthandCompoundProps"
|
|
9
|
-
>
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
>
|
|
10
|
+
import { useStudio } from '../studio/useStudio.js'
|
|
11
|
+
import type { ISheetObject, UnknownShorthandCompoundProps } from '@theatre/core'
|
|
12
|
+
import { currentWritable, useThrelte, watch, type CurrentWritable } from '@threlte/core'
|
|
13
|
+
import { getContext, onDestroy, onMount } from 'svelte'
|
|
14
|
+
import type { SheetContext } from '../sheet/types.js'
|
|
15
|
+
import Declare from './declare/Declare.svelte'
|
|
16
|
+
import type { SheetObjectProps } from './types.js'
|
|
17
|
+
import Sync from './sync/Sync.svelte'
|
|
18
|
+
import Transform from './transform/Transform.svelte'
|
|
19
|
+
import { createSheetContext } from './useSheet.js'
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
key,
|
|
23
|
+
detach = false,
|
|
24
|
+
props,
|
|
25
|
+
selected = $bindable(false),
|
|
26
|
+
onchange,
|
|
27
|
+
children
|
|
28
|
+
}: SheetObjectProps<Props> = $props()
|
|
29
|
+
|
|
30
|
+
const { invalidate } = useThrelte()
|
|
31
|
+
|
|
32
|
+
let aggregatedProps: UnknownShorthandCompoundProps = { ...props }
|
|
33
|
+
|
|
34
|
+
const { sheet } = getContext<SheetContext>('theatre-sheet')
|
|
35
|
+
|
|
36
|
+
const sheetObject: CurrentWritable<ISheetObject<Props>> = currentWritable(
|
|
37
|
+
sheet.object(key, aggregatedProps, {
|
|
38
|
+
reconfigure: true
|
|
39
|
+
}) as any
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
onMount(() => {
|
|
24
43
|
// Because the sheet object value subscription is not running before any
|
|
25
44
|
// values change, we're emitting the initial value here. Doing this in
|
|
26
45
|
// onMount also means that child components which might add props to the
|
|
27
46
|
// sheet object have already been mounted.
|
|
28
|
-
onchange?.(sheetObject.current.value)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
onchange?.(sheetObject.current.value)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// This flag is used to prevent the sheet object from being created after it
|
|
51
|
+
// has been detached.
|
|
52
|
+
let detached = false
|
|
53
|
+
onDestroy(() => {
|
|
34
54
|
if (detach) {
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
detached = true
|
|
56
|
+
sheet.detachObject(key)
|
|
37
57
|
}
|
|
38
|
-
})
|
|
39
|
-
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const updateSheetObject = () => {
|
|
40
61
|
// if the sheetObject has already been detached, do nothing.
|
|
41
|
-
if (detached)
|
|
42
|
-
|
|
62
|
+
if (detached) return
|
|
63
|
+
|
|
43
64
|
// first, detach the sheet object.
|
|
44
|
-
sheet.detachObject(key)
|
|
65
|
+
sheet.detachObject(key)
|
|
66
|
+
|
|
45
67
|
// create or reconfigure a sheet object here.
|
|
46
|
-
sheetObject.set(
|
|
68
|
+
sheetObject.set(
|
|
69
|
+
sheet.object(key, aggregatedProps, {
|
|
47
70
|
reconfigure: true
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
}) as any
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const addProps = (props: UnknownShorthandCompoundProps) => {
|
|
51
76
|
// add props to list of props
|
|
52
77
|
aggregatedProps = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
78
|
+
...aggregatedProps,
|
|
79
|
+
...props
|
|
80
|
+
}
|
|
56
81
|
// update sheet object (create or reconfigure)
|
|
57
|
-
updateSheetObject()
|
|
58
|
-
}
|
|
59
|
-
|
|
82
|
+
updateSheetObject()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const removeProps = (propNames: string[]) => {
|
|
60
86
|
// remove props from sheet object
|
|
61
87
|
propNames.forEach((prop) => {
|
|
62
|
-
|
|
63
|
-
})
|
|
88
|
+
delete aggregatedProps[prop]
|
|
89
|
+
})
|
|
90
|
+
|
|
64
91
|
// if there are no more props, detach sheet object
|
|
65
92
|
if (Object.keys(aggregatedProps).length === 0) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
// detach sheet object
|
|
94
|
+
if (detach) {
|
|
95
|
+
sheet.detachObject(key)
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
// update sheet object (reconfigure)
|
|
99
|
+
updateSheetObject()
|
|
70
100
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
createSheetContext({
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
createSheetContext({
|
|
77
104
|
sheetObject,
|
|
78
105
|
addProps,
|
|
79
106
|
removeProps
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
let values = $state($sheetObject?.value)
|
|
110
|
+
|
|
111
|
+
watch(sheetObject, (sheetObject) => {
|
|
83
112
|
return sheetObject.onValuesChange((newValues) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
113
|
+
onchange?.(newValues)
|
|
114
|
+
values = newValues
|
|
115
|
+
// this invalidation also invalidates changes catched by slotted
|
|
116
|
+
// components such as <Sync> or <Declare>.
|
|
117
|
+
invalidate()
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Provide a flag to indicate whether this sheet object is selected in the
|
|
122
|
+
// Theatre.js studio.
|
|
123
|
+
const studio = useStudio()
|
|
124
|
+
|
|
125
|
+
watch([studio, sheetObject], ([studio, sheetObject]) => {
|
|
95
126
|
return studio?.onSelectionChange((selection) => {
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
127
|
+
selected = selection.includes(sheetObject)
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// Provide a select function to select this sheet object in the Theatre.js
|
|
132
|
+
// studio.
|
|
133
|
+
const select = () => {
|
|
134
|
+
$studio?.setSelection([sheetObject.current])
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const deselect = () => {
|
|
105
138
|
if ($studio?.selection.includes(sheetObject.current)) {
|
|
106
|
-
|
|
139
|
+
$studio?.setSelection([])
|
|
107
140
|
}
|
|
108
|
-
}
|
|
141
|
+
}
|
|
109
142
|
</script>
|
|
110
143
|
|
|
111
144
|
{@render children?.({
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { UnknownShorthandCompoundProps } from '@theatre/core';
|
|
2
|
-
import type { SheetObjectProps } from './types';
|
|
2
|
+
import type { SheetObjectProps } from './types.js';
|
|
3
|
+
declare function $$render<Props extends UnknownShorthandCompoundProps>(): {
|
|
4
|
+
props: SheetObjectProps<Props>;
|
|
5
|
+
exports: {};
|
|
6
|
+
bindings: "selected";
|
|
7
|
+
slots: {};
|
|
8
|
+
events: {};
|
|
9
|
+
};
|
|
3
10
|
declare class __sveltets_Render<Props extends UnknownShorthandCompoundProps> {
|
|
4
|
-
props():
|
|
5
|
-
events():
|
|
6
|
-
slots():
|
|
11
|
+
props(): ReturnType<typeof $$render<Props>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<Props>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<Props>>['slots'];
|
|
7
14
|
bindings(): "selected";
|
|
8
15
|
exports(): {};
|
|
9
16
|
}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
<script
|
|
2
2
|
lang="ts"
|
|
3
3
|
generics="P extends UnknownShorthandCompoundProps"
|
|
4
|
-
>
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
|
|
4
|
+
>
|
|
5
|
+
import type { UnknownShorthandCompoundProps } from '@theatre/core'
|
|
6
|
+
import { watch } from '@threlte/core'
|
|
7
|
+
import { onDestroy } from 'svelte'
|
|
8
|
+
import { useSheet } from '../useSheet.js'
|
|
9
|
+
import type { DeclareProps } from './types.js'
|
|
10
|
+
|
|
11
|
+
let { props, children }: DeclareProps<P> = $props()
|
|
12
|
+
|
|
13
|
+
const { sheetObject, addProps, removeProps } = useSheet<P>()
|
|
14
|
+
|
|
15
|
+
let values = $state($sheetObject?.value)
|
|
16
|
+
|
|
17
|
+
addProps(props)
|
|
18
|
+
|
|
19
|
+
onDestroy(() => {
|
|
20
|
+
removeProps(Object.keys(props))
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
watch(sheetObject, (sheetObject) => {
|
|
15
24
|
return sheetObject?.onValuesChange((v) => {
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
})
|
|
25
|
+
values = v
|
|
26
|
+
})
|
|
27
|
+
})
|
|
19
28
|
</script>
|
|
20
29
|
|
|
21
30
|
{@render children?.({ values })}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { UnknownShorthandCompoundProps } from '@theatre/core';
|
|
2
|
-
import type { DeclareProps } from './types';
|
|
2
|
+
import type { DeclareProps } from './types.js';
|
|
3
|
+
declare function $$render<P extends UnknownShorthandCompoundProps>(): {
|
|
4
|
+
props: DeclareProps<P>;
|
|
5
|
+
exports: {};
|
|
6
|
+
bindings: "";
|
|
7
|
+
slots: {};
|
|
8
|
+
events: {};
|
|
9
|
+
};
|
|
3
10
|
declare class __sveltets_Render<P extends UnknownShorthandCompoundProps> {
|
|
4
|
-
props():
|
|
5
|
-
events():
|
|
6
|
-
slots():
|
|
11
|
+
props(): ReturnType<typeof $$render<P>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<P>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<P>>['slots'];
|
|
7
14
|
bindings(): "";
|
|
8
15
|
exports(): {};
|
|
9
16
|
}
|
|
@@ -1,48 +1,69 @@
|
|
|
1
1
|
<script
|
|
2
2
|
lang="ts"
|
|
3
3
|
generics="Type"
|
|
4
|
-
>
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
>
|
|
5
|
+
import { resolvePropertyPath, useParent, watch } from '@threlte/core'
|
|
6
|
+
import { onDestroy } from 'svelte'
|
|
7
|
+
import { useStudio } from '../../studio/useStudio.js'
|
|
8
|
+
import type { Transformer } from '../transfomers/types.js'
|
|
9
|
+
import { useSheet } from '../useSheet.js'
|
|
10
|
+
import type { AnyProp, SyncProps } from './types.js'
|
|
11
|
+
import { getInitialValue } from './utils/getInitialValue.js'
|
|
12
|
+
import { isComplexProp } from './utils/isComplexProp.js'
|
|
13
|
+
import { isStringProp } from './utils/isStringProp.js'
|
|
14
|
+
import { makeAlphanumeric } from './utils/makeAlphanumeric.js'
|
|
15
|
+
import { parsePropLabel } from './utils/parsePropLabel.js'
|
|
16
|
+
|
|
17
|
+
let { type, children, ...rest }: SyncProps<Type> = $props()
|
|
18
|
+
|
|
19
|
+
const { sheetObject, addProps, removeProps } = useSheet()
|
|
20
|
+
const parent = useParent()
|
|
21
|
+
|
|
22
|
+
// serves as a map to map (custom) prop names to object target properties
|
|
23
|
+
let propMappings = {} as Record<
|
|
24
|
+
string,
|
|
25
|
+
{
|
|
26
|
+
propertyPath: string
|
|
27
|
+
transformer: Transformer
|
|
28
|
+
}
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
const initProps = () => {
|
|
32
|
+
const props = {} as Record<string, any>
|
|
33
|
+
|
|
20
34
|
// propertyPath is for example "position.x" or "intensity", so a property path on the parent object
|
|
21
|
-
Object.entries(rest).forEach(([propertyPath, propertyValue]) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
Object.entries(<Record<string, AnyProp>>rest).forEach(([propertyPath, propertyValue]) => {
|
|
36
|
+
// The prop might have a custom name, for example "intensity" might be mapped to "light-intensity"
|
|
37
|
+
const customKey = isComplexProp(propertyValue)
|
|
38
|
+
? propertyValue.key
|
|
39
|
+
: isStringProp(propertyValue)
|
|
40
|
+
? propertyValue
|
|
41
|
+
: undefined
|
|
42
|
+
|
|
43
|
+
const key = customKey ?? makeAlphanumeric(propertyPath)
|
|
44
|
+
|
|
45
|
+
// get the initial value as well as the correct transformer for the property
|
|
46
|
+
const { value, transformer } = getInitialValue(propertyPath, propertyValue, $parent)
|
|
47
|
+
const label = parsePropLabel(key, propertyValue)
|
|
48
|
+
|
|
49
|
+
// apply the label to the value
|
|
50
|
+
value.label = label
|
|
51
|
+
|
|
52
|
+
// add the prop to the propMappings map
|
|
53
|
+
propMappings[key] = {
|
|
54
|
+
propertyPath,
|
|
55
|
+
transformer
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// add the prop to the props object
|
|
59
|
+
props[key] = value
|
|
60
|
+
})
|
|
61
|
+
|
|
42
62
|
// add the props to the parent IsheetObject
|
|
43
|
-
addProps(props)
|
|
44
|
-
}
|
|
45
|
-
|
|
63
|
+
addProps(props)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const updateProjectionMatrixKeys = [
|
|
46
67
|
'fov',
|
|
47
68
|
'near',
|
|
48
69
|
'far',
|
|
@@ -52,54 +73,70 @@ const updateProjectionMatrixKeys = [
|
|
|
52
73
|
'top',
|
|
53
74
|
'bottom',
|
|
54
75
|
'aspect'
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
watch([parent, sheetObject], ([parent, sheetObject]) => {
|
|
79
|
+
if (!parent) return
|
|
80
|
+
|
|
59
81
|
return sheetObject?.onValuesChange((values) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const propMapping = propMappings[key];
|
|
64
|
-
if (!propMapping)
|
|
65
|
-
return;
|
|
66
|
-
// we're using the addedProps map to infer the target property name from the property name on values
|
|
67
|
-
const { target, key: targetKey } = resolvePropertyPath(parent, propMapping.propertyPath);
|
|
68
|
-
// use a transformer to apply value
|
|
69
|
-
const transformer = propMapping.transformer;
|
|
70
|
-
transformer.apply(target, targetKey, values[key]);
|
|
71
|
-
if (updateProjectionMatrixKeys.includes(targetKey)) {
|
|
72
|
-
target.updateProjectionMatrix?.();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
initProps();
|
|
78
|
-
const studio = useStudio();
|
|
79
|
-
/**
|
|
80
|
-
* Capture the current values of the props
|
|
81
|
-
*/
|
|
82
|
-
export const capture = () => {
|
|
83
|
-
if (!$studio)
|
|
84
|
-
return;
|
|
85
|
-
const scrub = $studio.scrub();
|
|
86
|
-
Object.keys(sheetObject.current.value).forEach((key) => {
|
|
82
|
+
// Ensure that the parent is still mounted
|
|
83
|
+
|
|
84
|
+
Object.keys(values).forEach((key) => {
|
|
87
85
|
// first, check if the prop is mapped in this component
|
|
88
|
-
const propMapping = propMappings[key]
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const propMapping = propMappings[key]
|
|
87
|
+
|
|
88
|
+
if (!propMapping) return
|
|
89
|
+
|
|
91
90
|
// we're using the addedProps map to infer the target property name from the property name on values
|
|
92
|
-
const { target, key: targetKey } = resolvePropertyPath(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
const { target, key: targetKey } = resolvePropertyPath(
|
|
92
|
+
parent as any,
|
|
93
|
+
propMapping.propertyPath
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
// use a transformer to apply value
|
|
97
|
+
const transformer = propMapping.transformer
|
|
98
|
+
transformer.apply(target, targetKey, values[key])
|
|
99
|
+
|
|
100
|
+
if (updateProjectionMatrixKeys.includes(targetKey)) {
|
|
101
|
+
target.updateProjectionMatrix?.()
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
initProps()
|
|
108
|
+
|
|
109
|
+
const studio = useStudio()
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Capture the current values of the props
|
|
113
|
+
*/
|
|
114
|
+
export const capture = () => {
|
|
115
|
+
if (!$studio) return
|
|
116
|
+
const scrub = $studio.scrub()
|
|
117
|
+
|
|
118
|
+
Object.keys(sheetObject.current.value).forEach((key) => {
|
|
119
|
+
// first, check if the prop is mapped in this component
|
|
120
|
+
const propMapping = propMappings[key]
|
|
121
|
+
|
|
122
|
+
if (!propMapping) return
|
|
123
|
+
|
|
124
|
+
// we're using the addedProps map to infer the target property name from the property name on values
|
|
125
|
+
const { target, key: targetKey } = resolvePropertyPath($parent, propMapping.propertyPath)
|
|
126
|
+
|
|
127
|
+
const value = propMapping.transformer.transform(target[targetKey]).default
|
|
128
|
+
|
|
129
|
+
scrub.capture(({ set }) => {
|
|
130
|
+
set(sheetObject.current.props[key], value)
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
scrub.commit()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onDestroy(() => {
|
|
138
|
+
removeProps(Object.keys(propMappings))
|
|
139
|
+
})
|
|
103
140
|
</script>
|
|
104
141
|
|
|
105
142
|
{@render children?.({ capture })}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import type { SyncProps } from './types';
|
|
1
|
+
import type { SyncProps } from './types.js';
|
|
2
|
+
declare function $$render<Type>(): {
|
|
3
|
+
props: SyncProps<Type>;
|
|
4
|
+
exports: {
|
|
5
|
+
/**
|
|
6
|
+
* Capture the current values of the props
|
|
7
|
+
*/ capture: () => void;
|
|
8
|
+
};
|
|
9
|
+
bindings: "";
|
|
10
|
+
slots: {};
|
|
11
|
+
events: {};
|
|
12
|
+
};
|
|
2
13
|
declare class __sveltets_Render<Type> {
|
|
3
|
-
props():
|
|
4
|
-
events():
|
|
5
|
-
slots():
|
|
14
|
+
props(): ReturnType<typeof $$render<Type>>['props'];
|
|
15
|
+
events(): ReturnType<typeof $$render<Type>>['events'];
|
|
16
|
+
slots(): ReturnType<typeof $$render<Type>>['slots'];
|
|
6
17
|
bindings(): "";
|
|
7
18
|
exports(): {
|
|
8
19
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { ConditionalKeys, Primitive } from 'type-fest';
|
|
3
|
-
import type { Transformer } from '../transfomers/types';
|
|
3
|
+
import type { Transformer } from '../transfomers/types.js';
|
|
4
4
|
type OmittedPropKeys = 'type' | 'args' | 'attach' | 'manual' | 'makeDefault' | 'id' | 'children' | `is${string}` | 'parent' | 'uuid' | 'name';
|
|
5
5
|
type AnyClass = new (...args: any) => any;
|
|
6
6
|
type AnyFn = (...args: any) => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolvePropertyPath } from '@threlte/core';
|
|
2
|
-
import { getDefaultTransformer } from '../../transfomers/getDefaultTransformer';
|
|
3
|
-
import { isComplexProp } from './isComplexProp';
|
|
2
|
+
import { getDefaultTransformer } from '../../transfomers/getDefaultTransformer.js';
|
|
3
|
+
import { isComplexProp } from './isComplexProp.js';
|
|
4
4
|
export const getInitialValue = (propertyPath, propertyValue, targetObject) => {
|
|
5
5
|
const { target, key } = resolvePropertyPath(targetObject, propertyPath);
|
|
6
6
|
const rawValue = target[key];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AnyProp, ComplexProp } from '../types';
|
|
1
|
+
import type { AnyProp, ComplexProp } from '../types.js';
|
|
2
2
|
export declare const isComplexProp: (prop: AnyProp) => prop is ComplexProp;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AnyProp } from '../types';
|
|
1
|
+
import type { AnyProp } from '../types.js';
|
|
2
2
|
export declare const isStringProp: (prop: AnyProp) => prop is string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AnyProp } from '../types';
|
|
1
|
+
import type { AnyProp } from '../types.js';
|
|
2
2
|
export declare const parsePropLabel: (alphaNumericKey: string, propValue: AnyProp) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Transformer } from './types';
|
|
1
|
+
import type { Transformer } from './types.js';
|
|
2
2
|
export declare const createTransformer: (transformer: Transformer) => Transformer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const color: import("../types").Transformer;
|
|
1
|
+
export declare const color: import("../types.js").Transformer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { types } from '../../../theatre';
|
|
2
|
-
import { createTransformer } from '../createTransformer';
|
|
1
|
+
import { types } from '../../../theatre.js';
|
|
2
|
+
import { createTransformer } from '../createTransformer.js';
|
|
3
3
|
import { Color, SRGBColorSpace } from 'three';
|
|
4
4
|
const _color = new Color();
|
|
5
5
|
export const color = createTransformer({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const degrees: import("../types").Transformer;
|
|
1
|
+
export declare const degrees: import("../types.js").Transformer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils.js';
|
|
2
|
-
import { createTransformer } from '../createTransformer';
|
|
3
|
-
import { types } from '../../../theatre';
|
|
2
|
+
import { createTransformer } from '../createTransformer.js';
|
|
3
|
+
import { types } from '../../../theatre.js';
|
|
4
4
|
export const degrees = createTransformer({
|
|
5
5
|
transform(target) {
|
|
6
6
|
return types.number(target * RAD2DEG);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const euler: import("../types").Transformer;
|
|
1
|
+
export declare const euler: import("../types.js").Transformer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEG2RAD, RAD2DEG } from 'three/src/math/MathUtils.js';
|
|
2
|
-
import { createTransformer } from '../createTransformer';
|
|
3
|
-
import { types } from '../../../theatre';
|
|
2
|
+
import { createTransformer } from '../createTransformer.js';
|
|
3
|
+
import { types } from '../../../theatre.js';
|
|
4
4
|
export const euler = createTransformer({
|
|
5
5
|
transform(value) {
|
|
6
6
|
return types.compound({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generic: import("../types").Transformer;
|
|
1
|
+
export declare const generic: import("../types.js").Transformer;
|