title category import { OrbitControl } from "@oasis-engine/controls" ; import { AssetType , Camera , Entity , Sprite , SpriteRenderer , Texture2D , WebGLEngine } from "oasis-engine" ; const engine = new WebGLEngine ( "canvas" ) ; engine . canvas . resizeByClientSize ( ) ; const rootEntity = engine . sceneManager . activeScene . createRootEntity ( ) ; const cameraEntity = rootEntity . createChild ( "Camera" ) ; cameraEntity . transform . setPosition ( 0 , 0 , 50 ) ; cameraEntity . addComponent ( Camera ) ; cameraEntity . addComponent ( OrbitControl ) ; engine . resourceManager . load < Texture2D > ( { url : "https://gw.alipayobjects.com/mdn/rms_7c464e/afts/img/A*KjnzTpE8LdAAAAAAAAAAAAAAARQnAQ" , type : AssetType . Texture2D } ) . then ( ( texture ) => { const spriteEntity = new Entity ( engine , "spriteFlip" ) ; const spriteRenderer = spriteEntity . addComponent ( SpriteRenderer ) ; spriteRenderer . sprite = new Sprite ( engine , texture ) ; addFlipEntity ( spriteEntity , - 15 , false , false ) ; addFlipEntity ( spriteEntity . clone ( ) , - 5 , true , false ) ; addFlipEntity ( spriteEntity . clone ( ) , 5 , false , true ) ; addFlipEntity ( spriteEntity . clone ( ) , 15 , true , true ) ; } ) ; engine . run ( ) ; /**
 * Add flip entity.
 */ function addFlipEntity ( entity , posX , flipX , flipY ) { rootEntity . addChild ( entity ) ; entity . transform . setPosition ( posX , 0 , 0 ) ; const flipRenderer = entity . getComponent ( SpriteRenderer ) ; flipRenderer . flipX = flipX ; flipRenderer . flipY = flipY ; }