Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sample): fix propertyAnimation. #173

Merged
merged 1 commit into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions samples/animation/Sample_PropertyAnimation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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, MeshRenderer, LitMaterial, PropertyAnimClip, WrapMode } from "@orillusion/core";
import { Scene3D, PropertyAnimation, Engine3D, Object3D, Object3DUtil, PropertyAnimClip, WrapMode } from "@orillusion/core";

class Sample_PropertyAnimation {
scene: Scene3D;
Expand All @@ -15,7 +15,8 @@ class Sample_PropertyAnimation {

await Engine3D.init();
let param = createSceneParam();
param.camera.distance = 10;
param.camera.distance = 16;
param.camera.pitch = -25;
param.light.intensity = 40;
let exampleScene = createExampleScene(param);

Expand All @@ -32,7 +33,7 @@ class Sample_PropertyAnimation {

async initScene(scene: Scene3D) {
// floor
let floor: Object3D = Object3DUtil.GetSingleCube(100, 0.1, 100, 1, 1, 1);
let floor: Object3D = Object3DUtil.GetSingleCube(16, 0.1, 16, 1, 1, 1);
scene.addChild(floor);

// load external model
Expand Down Expand Up @@ -70,13 +71,14 @@ class Sample_PropertyAnimation {
// restart the animation clip
GUIHelp.addFolder('Property Animation');
GUIHelp.addButton('Restart', () => {
this.animation.play('anim_0', true);
this.animation.play(this.animation.defaultClip, true);
});

let data = { Seek: 0, Speed: 1 };

// seek the animation to the specified time
GUIHelp.add(data, 'Seek', 0, 1, 0.01).onChange((v) => {
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);
});
Expand Down