-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature: You can set shadows to GUI rename class
- Loading branch information
Showing
19 changed files
with
537 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { BitmapTexture2D, Engine3D, Object3D, Scene3D, Texture, UIImageGroup, UIShadow, ViewPanel, makeAloneSprite } from "@orillusion/core"; | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { createExampleScene } from "@samples/utils/ExampleScene"; | ||
import { Stats } from "@orillusion/stats"; | ||
import { GUIUtil } from "@samples/utils/GUIUtil"; | ||
|
||
export class Sample_UIImageGroup { | ||
scene: Scene3D; | ||
imageGroup: UIImageGroup; | ||
|
||
async run() { | ||
Engine3D.setting.shadow.autoUpdate = true; | ||
Engine3D.setting.shadow.shadowBias = 0.002; | ||
|
||
GUIHelp.init(); | ||
|
||
await Engine3D.init(); | ||
let exampleScene = createExampleScene(); | ||
this.scene = exampleScene.scene; | ||
this.scene.addComponent(Stats); | ||
Engine3D.startRenderView(exampleScene.view); | ||
|
||
|
||
GUIHelp.open(); | ||
GUIHelp.endFolder(); | ||
|
||
await this.createImageGroup(); | ||
} | ||
|
||
async createImageGroup() { | ||
// enable ui canvas i | ||
let canvas = this.scene.view.enableUICanvas(0); | ||
//create UI root | ||
let panelRoot: Object3D = new Object3D(); | ||
//create panel | ||
let panel = panelRoot.addComponent(ViewPanel, { billboard: true }); | ||
canvas.addChild(panel.object3D); | ||
|
||
let bitmapTexture2D = new BitmapTexture2D(); | ||
bitmapTexture2D.flipY = true; | ||
await bitmapTexture2D.load('png/logo.png'); | ||
|
||
let uiNode = new Object3D(); | ||
panelRoot.addChild(uiNode); | ||
//create sprite sheet list | ||
this.imageGroup = this.createSpriteSheets(uiNode, bitmapTexture2D); | ||
let shadow = this.imageGroup.object3D.addComponent(UIShadow); | ||
|
||
GUIUtil.renderUIShadow(shadow, false); | ||
|
||
this.createGUI(); | ||
} | ||
|
||
private halfSize = 0; | ||
createGUI() { | ||
GUIHelp.addFolder('Position'); | ||
let xy = this.imageGroup.getXY(1); | ||
let pos = { x: 0, y: xy.y }; | ||
let action = () => this.imageGroup.setXY(1, pos.x, pos.y); | ||
GUIHelp.add(pos, 'x', - Engine3D.width * 0.5, Engine3D.width * 0.5, 1).onChange(action); | ||
GUIHelp.add(pos, 'y', - Engine3D.height * 0.5, Engine3D.height * 0.5, 1).onChange(action); | ||
GUIHelp.open(); | ||
GUIHelp.endFolder(); | ||
} | ||
|
||
private createSpriteSheets(root: Object3D, texture: Texture): UIImageGroup { | ||
let sprite = makeAloneSprite('KB3D_NTT_Ads_basecolor', texture); | ||
let imgGroup = root.addComponent(UIImageGroup, { count: 2 }); | ||
let size = 256; | ||
this.halfSize = size * 0.5; | ||
for (let i = 0; i < 2; i++) { | ||
imgGroup.setSprite(i, sprite); | ||
imgGroup.setSize(i, size, size); | ||
if (i == 1) { | ||
imgGroup.setXY(1, - this.halfSize, 128 - this.halfSize) | ||
} else { | ||
imgGroup.setXY(0, - this.halfSize, - this.halfSize) | ||
} | ||
} | ||
return imgGroup; | ||
|
||
} | ||
} |
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,52 @@ | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { createExampleScene } from "@samples/utils/ExampleScene"; | ||
import { Engine3D, Object3DUtil, Object3D, BitmapTexture2D, UIImage, makeAloneSprite, WorldPanel, UIShadow } from "@orillusion/core"; | ||
import { GUIUtil } from "@samples/utils/GUIUtil"; | ||
|
||
export class Sample_UIImageShadow { | ||
private img: UIImage; | ||
|
||
async run() { | ||
Engine3D.setting.shadow.autoUpdate = true; | ||
Engine3D.setting.shadow.shadowBias = 0.002; | ||
|
||
GUIHelp.init(); | ||
|
||
await Engine3D.init(); | ||
let exampleScene = createExampleScene(); | ||
Engine3D.startRenderView(exampleScene.view); | ||
|
||
// create floor | ||
let floor = Object3DUtil.GetSingleCube(100, 2, 50, 0.5, 0.5, 0.5); | ||
exampleScene.scene.addChild(floor); | ||
|
||
//create UI root | ||
let panelRoot: Object3D = new Object3D(); | ||
panelRoot.scaleX = panelRoot.scaleY = panelRoot.scaleZ = 0.1; | ||
|
||
// enable ui canvas 0 | ||
|
||
let canvas = exampleScene.view.enableUICanvas(); | ||
|
||
let panel = panelRoot.addComponent(WorldPanel); | ||
canvas.addChild(panel.object3D); | ||
|
||
let imageQuad = new Object3D(); | ||
panelRoot.addChild(imageQuad); | ||
this.img = imageQuad.addComponent(UIImage); | ||
let bitmapTexture2D = new BitmapTexture2D(); | ||
bitmapTexture2D.flipY = true; | ||
await bitmapTexture2D.load('png/logo.png'); | ||
|
||
this.img.sprite = makeAloneSprite('KB3D_NTT_Ads_basecolor', bitmapTexture2D); | ||
this.img.uiTransform.resize(600, 600); | ||
this.img.uiTransform.y = 200; | ||
|
||
let shadow = imageQuad.addComponent(UIShadow); | ||
shadow.shadowQuality = 4; | ||
shadow.shadowRadius = 4; | ||
shadow.shadowOffset = shadow.shadowOffset.set(6, -6); | ||
GUIUtil.renderUIShadow(shadow, true); | ||
} | ||
|
||
} |
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,7 @@ | ||
export enum GUIQuadAttrEnum { | ||
NONE = 0, | ||
POSITION = 1 << 0, | ||
SPRITE = 1 << 1, | ||
COLOR = 1 << 2, | ||
MAX = POSITION + COLOR + SPRITE | ||
} |
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
Oops, something went wrong.