-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* checking in working state hey pixel interface * working text block generationg * fix the fallbacks * pro * adds pro mirror block * add basic edit component * adds transform controls to edit component * add editor plugin provider * add plugin system * checking in working plugin system but broken render * dont lose the nights work * working editor state mirror block * standardize the id object * check in nights work * working context bridge * build commands * adds build script * build directory * fixes example mirror block. working state. * add empty build directories * add empty build directories * add ignore and keeps for build folders so script can build on a fresh pull * remove old file * adds ignore for the pro folder * remove pro * remove pro folder * set block object * remove pro cruft * remove more pro cruft * remove messy comments * adjusts readme * tested up to * fixes static method
- Loading branch information
Showing
22 changed files
with
515 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { useFrontPlugins, FrontPluginContext } from './FrontPluginProvider'; | ||
import { useContextBridge } from "@react-three/drei"; | ||
|
||
//import contextBridgef | ||
// add function for context | ||
export function ContextBridgeComponent(props) { | ||
const { plugins } = useFrontPlugins(); // From your own context | ||
const [registeredThreeovBlocks, setRegisteredThreeovBlocks] = useState([]); | ||
const ContextBridge = useContextBridge(FrontPluginContext); | ||
|
||
useEffect(() => { | ||
if (plugins.length > 0) { | ||
plugins.forEach((plugin) => { | ||
// add the plugin to the registered blocks | ||
setRegisteredThreeovBlocks((registeredThreeovBlocks) => [ | ||
...registeredThreeovBlocks, | ||
plugin, | ||
]); | ||
}); | ||
} | ||
}, [plugins]); | ||
|
||
return ( | ||
<ContextBridge> | ||
{ | ||
registeredThreeovBlocks.length > 0 && registeredThreeovBlocks.map((blockElement, index) => { | ||
const BlockComponent = blockElement.type; | ||
return ( | ||
<group | ||
key={index} | ||
position={[0, 0, 0]} | ||
rotation={[0, 0, 0]} | ||
scale={[1, 1, 1]} | ||
> | ||
<BlockComponent key={index} {...blockElement.props} /> | ||
</group> | ||
) | ||
}) | ||
} | ||
</ContextBridge> | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { useState, useContext, useEffect, useCallback } from "react"; | ||
|
||
export const EditorPluginContext = React.createContext(); | ||
|
||
export function EditorPluginProvider({ children }) { | ||
|
||
const [plugins, setPlugins] = useState([]); | ||
|
||
const registerEditorPlugin = useCallback((plugin) => { | ||
setPlugins(prevPlugins => [...prevPlugins, plugin]); | ||
}, []); | ||
|
||
useEffect(() => { | ||
// Expose the registerPlugin method globally | ||
window.registerEditorPlugin = registerEditorPlugin; | ||
window.dispatchEvent(new Event('registerEditorPluginReady')); | ||
|
||
return () => { | ||
// Cleanup | ||
window.registerEditorPlugin = null; | ||
}; | ||
}, [registerEditorPlugin]); | ||
|
||
return ( | ||
<EditorPluginContext.Provider value={{ plugins, registerEditorPlugin }}> | ||
{children} | ||
</EditorPluginContext.Provider> | ||
); | ||
} | ||
|
||
export const useEditorPlugins = () => useContext(EditorPluginContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { createContext, useContext, useState, useEffect, useCallback } from "react"; | ||
import { useThree } from '@react-three/fiber'; | ||
|
||
export const FrontPluginContext = React.createContext(); | ||
|
||
export function FrontPluginProvider({ children }) { | ||
|
||
const [plugins, setPlugins] = useState([]); | ||
const { scene, camera } = useThree(); | ||
|
||
const registerFrontPlugin = useCallback((plugin) => { | ||
setPlugins(prevPlugins => [...prevPlugins, plugin]); | ||
}, []); | ||
|
||
useEffect(() => { | ||
// Expose the registerPlugin method globally | ||
window.registerFrontPlugin = registerFrontPlugin; | ||
window.dispatchEvent(new Event('registerFrontPluginReady')); | ||
|
||
return () => { | ||
// Cleanup | ||
window.registerFrontPlugin = null; | ||
}; | ||
}, [registerFrontPlugin]); | ||
|
||
return ( | ||
<FrontPluginContext.Provider value={{ plugins, registerFrontPlugin, scene, camera }}> | ||
{children} | ||
</FrontPluginContext.Provider> | ||
); | ||
} | ||
|
||
export const useFrontPlugins = () => useContext(FrontPluginContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.