-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
153 changed files
with
6,373 additions
and
732 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ jobs: | |
|
||
- name: Test in Electron | ||
run: pnpm run test:ci | ||
timeout-minutes: 5 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,96 @@ | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { createExampleScene, createSceneParam } from "@samples/utils/ExampleScene"; | ||
import { GUIUtil } from "@samples/utils/GUIUtil"; | ||
import { Scene3D, PropertyAnimation, Engine3D, Object3D, Object3DUtil, PropertyAnimClip, WrapMode } from "@orillusion/core"; | ||
|
||
class Sample_PropertyAnimation { | ||
scene: Scene3D; | ||
animation: PropertyAnimation; | ||
|
||
async run() { | ||
Engine3D.setting.shadow.autoUpdate = true; | ||
Engine3D.setting.shadow.updateFrameRate = 1; | ||
Engine3D.setting.shadow.shadowBound = 20; | ||
Engine3D.setting.shadow.shadowBias = 0.0001; | ||
|
||
await Engine3D.init(); | ||
let param = createSceneParam(); | ||
param.camera.distance = 16; | ||
param.camera.pitch = -25; | ||
param.light.intensity = 40; | ||
let exampleScene = createExampleScene(param); | ||
|
||
GUIHelp.init(); | ||
GUIUtil.renderDirLight(exampleScene.light, false); | ||
|
||
this.scene = exampleScene.scene; | ||
await this.initScene(this.scene); | ||
|
||
Engine3D.startRenderView(exampleScene.view); | ||
|
||
this.displayGUI(); | ||
} | ||
|
||
async initScene(scene: Scene3D) { | ||
// floor | ||
let floor: Object3D = Object3DUtil.GetSingleCube(16, 0.1, 16, 1, 1, 1); | ||
scene.addChild(floor); | ||
|
||
// load external model | ||
let model = await Engine3D.res.loadGltf('PBR/Duck/Duck.gltf') as Object3D; | ||
let container = new Object3D(); | ||
container.addChild(model); | ||
model.rotationY = 180; | ||
this.scene.addChild(container); | ||
model.scaleX = model.scaleY = model.scaleZ = 0.01; | ||
|
||
this.animation = await this.initPropertyAnim(container); | ||
this.animation.play(this.animation.defaultClip); | ||
|
||
return true; | ||
} | ||
|
||
private async initPropertyAnim(owner: Object3D) { | ||
// add PropertyAnimation | ||
let animation = owner.addComponent(PropertyAnimation); | ||
|
||
//load a animation clip | ||
let json: any = await Engine3D.res.loadJSON('json/anim_0.json'); | ||
let animClip = new PropertyAnimClip(); | ||
animClip.parse(json); | ||
animClip.wrapMode = WrapMode.Loop; | ||
animation.defaultClip = animClip.name; | ||
animation.autoPlay = true; | ||
|
||
// register clip to animation | ||
animation.appendClip(animClip); | ||
return animation; | ||
} | ||
|
||
private displayGUI() { | ||
// restart the animation clip | ||
GUIHelp.addFolder('Property Animation'); | ||
GUIHelp.addButton('Restart', () => { | ||
this.animation.play(this.animation.defaultClip, true); | ||
}); | ||
|
||
let data = { Seek: 0, Speed: 1 }; | ||
|
||
// seek the animation to the specified time | ||
let totalTime = this.animation.getClip(this.animation.defaultClip).totalTime; | ||
GUIHelp.add(data, 'Seek', 0, totalTime, 0.01).onChange((v) => { | ||
this.animation.stop(); | ||
this.animation.seek(v); | ||
}); | ||
|
||
// change animation speed | ||
GUIHelp.add(data, 'Speed', 0, 1, 0.01).onChange((v) => { | ||
this.animation.speed = v; | ||
}); | ||
|
||
GUIHelp.open(); | ||
GUIHelp.endFolder(); | ||
} | ||
} | ||
|
||
new Sample_PropertyAnimation().run(); |
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.