Skip to content

Commit

Permalink
fix(sample): fix propertyAnimation. (#173)
Browse files Browse the repository at this point in the history
Replace the name of the default animation clip with the hard code parameter
  • Loading branch information
hellmor committed May 24, 2023
1 parent 5c7c6ef commit c35e838
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit c35e838

Please sign in to comment.