mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
所有Player创建函数返回Promise。
This commit is contained in:
parent
c0982c28c7
commit
a4ce24f065
@ -135,7 +135,7 @@ PostProcessingComponent.prototype.render = function () {
|
||||
xtype: 'number',
|
||||
id: 'bokehMaxBlur',
|
||||
scope: this.id,
|
||||
value: 1.0,
|
||||
value: 0.05,
|
||||
onChange: this.onChange.bind(this)
|
||||
}]
|
||||
}]
|
||||
|
||||
@ -88,17 +88,18 @@ Player.prototype.start = function () {
|
||||
this.loader.create(jsons).then(obj => {
|
||||
this.initPlayer(obj);
|
||||
|
||||
this.event.create(this.scene, this.camera, this.renderer, obj.scripts);
|
||||
this.control.create(this.scene, this.camera, this.renderer);
|
||||
this.audio.create(this.scene, this.camera, this.renderer, this.loader);
|
||||
this.playerRenderer.create(this.scene, this.camera, this.renderer);
|
||||
this.animation.create(this.scene, this.camera, this.renderer, obj.animation);
|
||||
this.physics.create(this.scene, this.camera, this.renderer);
|
||||
|
||||
this.clock.start();
|
||||
this.event.init();
|
||||
this.event.start();
|
||||
var promise1 = this.event.create(this.scene, this.camera, this.renderer, obj.scripts);
|
||||
var promise2 = this.control.create(this.scene, this.camera, this.renderer);
|
||||
var promise3 = this.audio.create(this.scene, this.camera, this.renderer, this.loader);
|
||||
var promise4 = this.playerRenderer.create(this.scene, this.camera, this.renderer);
|
||||
var promise5 = this.animation.create(this.scene, this.camera, this.renderer, obj.animation);
|
||||
var promise6 = this.physics.create(this.scene, this.camera, this.renderer);
|
||||
|
||||
Promise.all([promise1, promise2, promise3, promise4, promise5, promise6]).then(() => {
|
||||
this.event.init();
|
||||
this.clock.start();
|
||||
this.event.start();
|
||||
});
|
||||
requestAnimationFrame(this.animate.bind(this));
|
||||
});
|
||||
};
|
||||
|
||||
@ -31,7 +31,11 @@ MMDAnimator.prototype.create = function (scene, camera, renderer, animations) {
|
||||
var helper = this.helper;
|
||||
|
||||
mmds.forEach(mesh => {
|
||||
let { animation, cameraAnimation, audio } = mesh.userData.obj;
|
||||
let {
|
||||
animation,
|
||||
cameraAnimation,
|
||||
audio
|
||||
} = mesh.userData.obj;
|
||||
|
||||
if (animation) {
|
||||
helper.add(mesh, {
|
||||
@ -52,11 +56,15 @@ MMDAnimator.prototype.create = function (scene, camera, renderer, animations) {
|
||||
|
||||
if (audio) {
|
||||
var audioParams = {
|
||||
delayTime: 160 * 1 / 30
|
||||
delayTime: 5
|
||||
};
|
||||
helper.add(audio, audioParams);
|
||||
}
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
MMDAnimator.prototype.update = function (clock, deltaTime) {
|
||||
@ -64,7 +72,7 @@ MMDAnimator.prototype.update = function (clock, deltaTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.helper.update(deltaTime);
|
||||
this.helper.update(deltaTime * 1.3);
|
||||
};
|
||||
|
||||
MMDAnimator.prototype.dispose = function () {
|
||||
|
||||
@ -14,6 +14,10 @@ ParticleAnimator.prototype.constructor = ParticleAnimator;
|
||||
|
||||
ParticleAnimator.prototype.create = function (scene, camera, renderer) {
|
||||
this.scene = scene;
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
ParticleAnimator.prototype.update = function (clock, deltaTime, time) {
|
||||
|
||||
@ -15,6 +15,10 @@ TweenAnimator.prototype.constructor = TweenAnimator;
|
||||
TweenAnimator.prototype.create = function (scene, camera, renderer, animations) {
|
||||
this.scene = scene;
|
||||
this.animations = animations;
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
TweenAnimator.prototype.update = function (clock, deltaTime, time) {
|
||||
|
||||
@ -36,13 +36,15 @@ PlayerAnimation.prototype.create = function (scene, camera, renderer, animations
|
||||
|
||||
this.maxTime = this.calculateMaxTime();
|
||||
|
||||
this.animators.forEach(n => {
|
||||
n.create(scene, camera, renderer, animations);
|
||||
});
|
||||
|
||||
this.app.call(`resetAnimation`, this);
|
||||
this.app.call(`startAnimation`, this);
|
||||
this.app.on(`animationTime.${this.id}`, this.updateTime.bind(this));
|
||||
|
||||
var promises = this.animators.map(n => {
|
||||
return n.create(scene, camera, renderer, animations);
|
||||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
PlayerAnimation.prototype.calculateMaxTime = function () {
|
||||
|
||||
@ -35,6 +35,10 @@ PlayerAudio.prototype.create = function (scene, camera, renderer, loader) {
|
||||
this.audios.push(n);
|
||||
}
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
PlayerAudio.prototype.dispose = function () {
|
||||
|
||||
@ -17,7 +17,9 @@ function PlayerComponent(app) {
|
||||
* @param {*} others
|
||||
*/
|
||||
PlayerComponent.prototype.create = function (scene, camera, renderer, others) {
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -50,6 +50,10 @@ PlayerControl.prototype.create = function (scene, camera, renderer) {
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
PlayerControl.prototype.update = function (clock, deltaTime) {
|
||||
|
||||
@ -73,6 +73,10 @@ PlayerEvent.prototype.create = function (scene, camera, renderer, scripts) {
|
||||
window.addEventListener('resize', n.onResize.bind(this.scene));
|
||||
}
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -55,6 +55,10 @@ PlayerPhysics.prototype.create = function (scene, camera, renderer) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
PlayerPhysics.prototype.update = function (clock, deltaTime) {
|
||||
|
||||
@ -51,7 +51,7 @@ PlayerRenderer.prototype.create = function (scene, camera, renderer) {
|
||||
if (postProcessing.bokeh && postProcessing.bokeh.enabled) {
|
||||
effect = new THREE.BokehPass(scene, camera, {
|
||||
focus: postProcessing.bokeh.focus,
|
||||
aperture: postProcessing.bokeh.aperture,
|
||||
aperture: postProcessing.bokeh.aperture / 100,
|
||||
maxblur: postProcessing.bokeh.maxBlur,
|
||||
width: renderer.domElement.width,
|
||||
height: renderer.domElement.height
|
||||
@ -69,6 +69,10 @@ PlayerRenderer.prototype.create = function (scene, camera, renderer) {
|
||||
}
|
||||
|
||||
this.composer = composer;
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
PlayerRenderer.prototype.update = function (clock, deltaTime) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user