fix: trivial, tweak time stuff

This commit is contained in:
FMS-Cat
2021-03-15 12:41:10 +09:00
parent 766d197654
commit 895c9c3fd7
2 changed files with 9 additions and 5 deletions

View File

@@ -106,9 +106,9 @@ export class Music {
const { audio, isPlaying } = this;
const genTime = audio.currentTime;
this.deltaTime = genTime - this.__prevAudioTime;
if ( isPlaying ) {
this.deltaTime = genTime - this.__prevAudioTime;
this.time += this.deltaTime;
const buffer = this.__bufferPool.next();
@@ -125,6 +125,8 @@ export class Music {
bufferSource.start( audio.currentTime, audio.currentTime - genTime );
this.__prevBufferSource = bufferSource;
} else {
this.deltaTime = 0.0;
this.__prevBufferSource?.stop( audio.currentTime );
this.__prevBufferSource = null;
}

View File

@@ -17,13 +17,15 @@ export class Cube {
public constructor() {
this.entity = new Entity();
this.entity.transform.rotation = Quaternion.fromAxisAngle(
const rot0 = Quaternion.fromAxisAngle(
new Vector3( [ 1.0, 0.0, 0.0 ] ),
0.4,
).multiply( Quaternion.fromAxisAngle(
new Vector3( [ 0.0, 0.0, 1.0 ] ),
0.4,
) );
this.entity.transform.rotation = rot0;
this.entity.transform.scale = this.entity.transform.scale.scale( 0.8 );
this.geometry = this.__createGeometry();
@@ -37,9 +39,9 @@ export class Cube {
this.entity.components.push( this.mesh );
this.entity.components.push( new Lambda( {
onUpdate: ( { deltaTime } ) => {
this.entity.transform.rotation = this.entity.transform.rotation.multiply(
Quaternion.fromAxisAngle( new Vector3( [ 0.0, 1.0, 0.0 ] ), deltaTime )
onUpdate: ( { time } ) => {
this.entity.transform.rotation = rot0.multiply(
Quaternion.fromAxisAngle( new Vector3( [ 0.0, 1.0, 0.0 ] ), time )
);
},
visible: false,