@@ -2,6 +2,7 @@ import { extname } from "path/posix";
22
33import { DragEvent , useEffect , useRef , useState } from "react" ;
44
5+ import { FaLock } from "react-icons/fa" ;
56import { useEventListener } from "usehooks-ts" ;
67
78import { Node , TransformNode , AbstractMesh } from "babylonjs" ;
@@ -12,6 +13,7 @@ import { isScene } from "../../../tools/guards/scene";
1213import { isSound } from "../../../tools/guards/sound" ;
1314import { registerUndoRedo } from "../../../tools/undoredo" ;
1415import { isAnyParticleSystem } from "../../../tools/guards/particles" ;
16+ import { isNodeSerializable , isNodeLocked } from "../../../tools/node/metadata" ;
1517import { isAbstractMesh , isInstancedMesh , isMesh , isNode , isTransformNode } from "../../../tools/guards/nodes" ;
1618
1719import { applySoundAsset } from "../preview/import/sound" ;
@@ -246,14 +248,50 @@ export function EditorGraphLabel(props: IEditorGraphLabelProps) {
246248 props . editor . layout . graph . refresh ( ) ;
247249 }
248250
251+ function getLabel ( ) {
252+ if ( doubleClicked ) {
253+ return (
254+ < Input
255+ value = { name }
256+ ref = { inputRef }
257+ className = "w-fit h-7"
258+ onCopy = { ( ev ) => ev . stopPropagation ( ) }
259+ onPaste = { ( ev ) => ev . stopPropagation ( ) }
260+ onChange = { ( ev ) => setName ( ev . currentTarget . value ) }
261+ />
262+ ) ;
263+ }
264+
265+ const label = (
266+ < div
267+ className = { `
268+ ${ ! isNodeSerializable ( props . object ) ? "line-through" : "" }
269+ ${ ! isNodeSerializable ( props . object ) || isNodeLocked ( props . object ) ? "text-foreground/35" : "" }
270+ transition-all duration-300 ease-in-out
271+ ` }
272+ >
273+ { props . name }
274+ </ div >
275+ ) ;
276+
277+ if ( isNodeLocked ( props . object ) ) {
278+ return (
279+ < div className = "flex gap-2 items-center justify-between" >
280+ { label }
281+ < FaLock className = "w-4 h-4 opacity-50 mr-2" />
282+ </ div >
283+ ) ;
284+ }
285+
286+ return label ;
287+ }
288+
249289 return (
250290 < div
251291 draggable
252292 className = { `
253293 ml-2 p-1 w-full
254294 ${ over ? "bg-muted" : "" }
255- ${ props . object . metadata ?. doNotSerialize ? "text-foreground/35 line-through" : "" }
256- transition-all duration-300 ease-in-out
257295 ` }
258296 onDragStart = { ( ev ) => handleDragStart ( ev ) }
259297 onDragOver = { ( ev ) => handleDragOver ( ev ) }
@@ -262,18 +300,7 @@ export function EditorGraphLabel(props: IEditorGraphLabelProps) {
262300 onDoubleClick = { ( ) => handleDoubleClick ( ) }
263301 onBlur = { ( ) => handleInputNameBlurred ( ) }
264302 >
265- { doubleClicked ? (
266- < Input
267- value = { name }
268- ref = { inputRef }
269- className = "w-fit h-7"
270- onCopy = { ( ev ) => ev . stopPropagation ( ) }
271- onPaste = { ( ev ) => ev . stopPropagation ( ) }
272- onChange = { ( ev ) => setName ( ev . currentTarget . value ) }
273- />
274- ) : (
275- props . name
276- ) }
303+ { getLabel ( ) }
277304 </ div >
278305 ) ;
279306}
0 commit comments