键盘控制的 3DEXCITE人体运动
在 3DEXCITE Creative Experience 应用程序中,您可以让 角色 在按下键盘按键时沿着预定义的路径移动。要实现这一点,我们首先需要设置动作行为,然后编写事件脚本,最后在故事叙述中配置场景。在本指南中,我们将引导您完成在 3DEXCITE,从而实现对角色动作的精确控制。
让我们一步一步地来!
首先,我们需要在场景中引入一个人类角色。.
现在人体模型已经建立,我们可以将重点转移到添加运动行为上。.
因此,人类将能够按照我们预先设定的事件沿着路径移动。.

在开始编写动作脚本之前,我们先来定义一下人将要遵循的路径。.
当脚本触发时,该路径将作为移动引导线。.

3DEXCITE中键盘输入的 JavaScript 技术
此时,我们需要设置一个 脚本角色 来处理键盘输入并触发人的动作。

var TriggerEventClass = function () {
EP.Event.apply(this, arguments);
};
TriggerEventClass.prototype = Object.create(EP.Event.prototype);
TriggerEventClass.prototype.constructor = TriggerEventClass;
TriggerEventClass.prototype.type = 'TriggerEventType';
if (!STU.TriggerEvent) {
STU.TriggerEvent = TriggerEventClass;
}
if (!EP.EventServices.getEventByType(TriggerEventClass.prototype.type)) {
EP.EventServices.registerEvent(TriggerEventClass);
}
beScript.onStart = function () {
// 脚本启动时要执行的代码。
};
beScript.onStop = function () {
// 当体验停止时要执行的代码。
};
beScript.execute = function (context) {
// 每帧执行一次。//
'context.deltaTime' 提供自上一帧以来经过的时间。
};
beScript.onAllKeyboardRelease = function (iEvent) {
// 取消注释以下行以调试按键释放事件。
// console.log(iEvent.key);
if (iEvent.key === this.KeyCode) {
let newEvent = new STU.TriggerEvent();
this.actor.dispatchEvent(newEvent);
}
};
让我们来分析一下这个脚本的作用以及它在 Creative Experience中的工作原理。.
var TriggerEventClass = function () {
EP.Event.apply(this, arguments);
};
的自定义事件类 TriggerEventClass。它扩展了 EP.Event 基类,使其在 Creative Experience。
TriggerEventClass.prototype = Object.create(EP.Event.prototype);
TriggerEventClass.prototype.constructor = TriggerEventClass;
TriggerEventClass.prototype.type = 'TriggerEventType';
在这里,我们基于 EP.Event ,并设置自定义事件类型 TriggerEventType。
在之前的博客中,我们探讨了如何使用 JavaScript 让用户沿着预定义的路径移动。如果您错过了,请继续阅读……