import { Alignment , OBS , Scene } from "@sceneify/core" ; import { ColorSource } from "@sceneify/sources" ; async function main ( ) { const obs = new OBS ( ) ; await obs . connect ( "ws:localhost:4444" ) ; await verifyLinkedSceneExists ( obs ) ; const { baseWidth : OBS_WIDTH , baseHeight : OBS_HEIGHT } = await obs . call ( "GetVideoSettings" ) ; const color = new ColorSource ( { name : "Color Source" , settings : { color : 0xffff0000 , width : 400 , height : 400 , } , filters : { } , } ) ; const mainScene = new Scene ( { name : "Main" , items : { red : { source : color , alignment : Alignment . Center , positionX : OBS_WIDTH / 2 , positionY : OBS_HEIGHT / 2 , } , } , } ) ; await mainScene . create ( obs ) ; await mainScene . makeCurrentScene ( ) ; await wait ( 1000 ) ; await mainScene . item ( "red" ) . source . setSettings ( { color : 0xff00ff00 , } ) ; await wait ( 1000 ) ; await wait ( 3000 ) ; const linkedScene = new Scene ( { name : "Linked Scene" , items : { color : { source : new ColorSource ( { name : "Linked Color Source" , } ) , alignment : Alignment . TopLeft , positionX : 0 , positionY : 0 , } , } , } ) ; await linkedScene . link ( obs , { setProperties : true , } ) ; await linkedScene . makeCurrentScene ( ) ; await wait ( 1000 ) ; await linkedScene . item ( "color" ) . setTransform ( { alignment : Alignment . BottomRight , positionX : OBS_WIDTH , positionY : OBS_HEIGHT , } ) ; await wait ( 3000 ) ; const finalSceen = new Scene ( { name : "Final Scene" , items : { main : { source : mainScene , positionX : OBS_WIDTH / 2 , positionY : OBS_HEIGHT / 2 , alignment : Alignment . Center , scaleX : 1 , scaleY : 1 , } , linked : { source : linkedScene , } , } , } ) ; await finalSceen . create ( obs ) ; await finalSceen . makeCurrentScene ( ) ; await wait ( 1000 ) ; await finalSceen . item ( "main" ) . setTransform ( { scaleX : 0.5 , scaleY : 0.5 , } ) ; } main ( ) ; const wait = ( ms ) => new Promise ( ( r ) => setTimeout ( r , ms ) ) ; async function verifyLinkedSceneExists ( obs ) { const { scenes } = await obs . call ( "GetSceneList" ) ; if ( ! scenes . some ( ( s ) => s . sceneName === "Linked Scene" ) ) { throw new Error ( "Linked Scene does not exist. Please create it." ) ; } const { sceneItems } = await obs . call ( "GetSceneItemList" , { sceneName : "Linked Scene" , } ) ; if ( ! sceneItems . some ( ( i ) => i . sourceName === "Linked Color Source" ) ) { throw new Error ( "Linked Color Source does not exist. Please create it inside Linked Scene." ) ; } }