Replace uniqueName with theatreKey (#285)

This commit is contained in:
Andrew Prifer 2022-09-14 19:36:49 +07:00 committed by GitHub
parent ce79d3cd95
commit 8680f9d89e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 111 additions and 111 deletions

View file

@ -58,13 +58,13 @@ const ProxyManager: VFC<ProxyManagerProps> = ({orbitControlsRef}) => {
sceneProxy.traverse((object) => {
if (object.userData.__editable) {
// there are duplicate uniqueNames in the scene, only display one instance in the editor
// there are duplicate theatreKeys in the scene, only display one instance in the editor
if (editableProxies[object.userData.__storeKey]) {
object.parent!.remove(object)
} else {
const uniqueName = object.userData.__storeKey
const theatreKey = object.userData.__storeKey
editableProxies[uniqueName] = {
editableProxies[theatreKey] = {
portal: createPortal(
<EditableProxy
storeKey={object.userData.__storeKey}
@ -73,7 +73,7 @@ const ProxyManager: VFC<ProxyManagerProps> = ({orbitControlsRef}) => {
object.parent!,
),
object: object,
editable: editables[uniqueName]!,
editable: editables[theatreKey]!,
}
}
}

View file

@ -21,7 +21,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
type: T extends 'primitive' ? null : U,
) => {
type Props = Omit<ComponentProps<T>, 'visible'> & {
uniqueName: string
theatreKey: string
visible?: boolean | 'editor'
additionalProps?: $FixMe
objRef?: $FixMe
@ -35,7 +35,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
return forwardRef(
(
{
uniqueName,
theatreKey,
visible,
editableType,
additionalProps,
@ -50,7 +50,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
const sheet = useCurrentSheet()!
const storeKey = makeStoreKey(sheet, uniqueName)
const storeKey = makeStoreKey(sheet, theatreKey)
const [sheetObject, setSheetObject] = useState<
undefined | ISheetObject<$FixMe>
@ -61,7 +61,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
useLayoutEffect(() => {
if (!sheet) return
const sheetObject = sheet.object(
uniqueName,
theatreKey,
Object.assign(
{
...additionalProps,
@ -164,7 +164,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
[Property in Keys]: React.ForwardRefExoticComponent<
React.PropsWithoutRef<
Omit<JSX.IntrinsicElements[Property], 'visible'> & {
uniqueName: string
theatreKey: string
visible?: boolean | 'editor'
additionalProps?: $FixMe
objRef?: $FixMe
@ -176,7 +176,7 @@ const createEditable = <Keys extends keyof JSX.IntrinsicElements>(
React.PropsWithoutRef<
{
object: any
uniqueName: string
theatreKey: string
visible?: boolean | 'editor'
additionalProps?: $FixMe
objRef?: $FixMe

View file

@ -44,11 +44,11 @@ export type EditorStore = {
init: (scene: Scene, gl: WebGLRenderer) => void
addEditable: (uniqueName: string, editable: Editable<any>) => void
addEditable: (theatreKey: string, editable: Editable<any>) => void
createSnapshot: () => void
setSnapshotProxyObject: (
proxyObject: Object3D | null,
uniqueName: string,
theatreKey: string,
) => void
}
@ -76,11 +76,11 @@ const config: StateCreator<EditorStore> = (set, get) => {
get().createSnapshot()
},
addEditable: (uniqueName, editable) => {
addEditable: (theatreKey, editable) => {
set((state) => ({
editables: {
...state.editables,
[uniqueName]: editable,
[theatreKey]: editable,
},
}))
},
@ -92,12 +92,12 @@ const config: StateCreator<EditorStore> = (set, get) => {
}))
},
setSnapshotProxyObject: (proxyObject, uniqueName) => {
setSnapshotProxyObject: (proxyObject, theatreKey) => {
set((state) => ({
editablesSnapshot: {
...state.editablesSnapshot,
[uniqueName]: {
...state.editablesSnapshot![uniqueName],
[theatreKey]: {
...state.editablesSnapshot![theatreKey],
proxyObject,
},
},