@oasis-engine/ark
Advanced tools
Comparing version 0.8.0-beta.2 to 0.8.0-beta.3
@@ -732,3 +732,3 @@ (function (global, factory) { | ||
this._setAnimationPromise = this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
var res, animations, animator, animatorController, layer, animatorStateMachine; | ||
var res, animations, animator, animatorController, layer, animatorStateMachine, clip, animatorState; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
@@ -757,13 +757,11 @@ while (1) { | ||
if (animations) { | ||
animations.forEach(function (clip) { | ||
var animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; | ||
}); | ||
} // @todo adapter updateAnimation | ||
clip = animations[0]; | ||
animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; // @todo adapter updateAnimation | ||
animator.speed = 1; | ||
animator.crossFade(clip.name, 0.3 / clip.length); | ||
} | ||
animator.speed = 1; | ||
animator.play(animations[0].name); | ||
case 15: | ||
case 13: | ||
case "end": | ||
@@ -792,4 +790,4 @@ return _context12.stop(); | ||
/** | ||
* Get time duration of animation clip by name. | ||
* @param clipName The name of the animation clip. | ||
* Get time duration of animation by glTF url. | ||
* @param url - The url of animation glTF file. | ||
* @returns The time duration in seconds. | ||
@@ -799,16 +797,36 @@ */ | ||
_proto.getAnimationDuration = function getAnimationDuration(clipName) { | ||
if (this._animationClips) { | ||
var clip = this._animationClips.find(function (_ref7) { | ||
var name = _ref7.name; | ||
return name === clipName; | ||
}); | ||
_proto.getAnimationDuration = | ||
/*#__PURE__*/ | ||
function () { | ||
var _getAnimationDuration = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(url) { | ||
var res, animations; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
_context14.next = 2; | ||
return this.engine.resourceManager.load({ | ||
type: oasisEngine.AssetType.Prefab, | ||
url: url | ||
}); | ||
if (clip) { | ||
return clip.length; | ||
} | ||
case 2: | ||
res = _context14.sent; | ||
animations = res.animations; | ||
return _context14.abrupt("return", animations[0].length); | ||
case 5: | ||
case "end": | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
})); | ||
function getAnimationDuration(_x8) { | ||
return _getAnimationDuration.apply(this, arguments); | ||
} | ||
return 0; | ||
} | ||
return getAnimationDuration; | ||
}() | ||
/** | ||
@@ -824,10 +842,10 @@ * @override | ||
_proto._replaceModel = /*#__PURE__*/function () { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(modelUrl) { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, renderers, rendererIndex, renderer, material, skinRenderers, _rendererIndex, _renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
_context14.next = 2; | ||
_context15.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -839,3 +857,3 @@ type: oasisEngine.AssetType.Prefab, | ||
case 2: | ||
res = _context14.sent; | ||
res = _context15.sent; | ||
@@ -899,9 +917,9 @@ this._destroyLastGLTF(); | ||
case "end": | ||
return _context14.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
}, _callee15, this); | ||
})); | ||
function _replaceModel(_x8) { | ||
function _replaceModel(_x9) { | ||
return _replaceModel3.apply(this, arguments); | ||
@@ -914,9 +932,9 @@ } | ||
_proto._loadModel = /*#__PURE__*/function () { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(url) { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(url) { | ||
var res, defaultSceneRoot; | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context15.next = 2; | ||
_context16.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -928,15 +946,15 @@ type: oasisEngine.AssetType.Prefab, | ||
case 2: | ||
res = _context15.sent; | ||
res = _context16.sent; | ||
defaultSceneRoot = res.defaultSceneRoot; | ||
return _context15.abrupt("return", defaultSceneRoot.clone()); | ||
return _context16.abrupt("return", defaultSceneRoot.clone()); | ||
case 5: | ||
case "end": | ||
return _context15.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee15, this); | ||
}, _callee16, this); | ||
})); | ||
function _loadModel(_x9) { | ||
function _loadModel(_x10) { | ||
return _loadModel2.apply(this, arguments); | ||
@@ -1038,8 +1056,8 @@ } | ||
if (this._setModelPromise) { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
var json, index, _json$index, name, value; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
@@ -1060,6 +1078,6 @@ try { | ||
case "end": | ||
return _context16.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee16); | ||
}, _callee17); | ||
}))); | ||
@@ -1066,0 +1084,0 @@ } |
@@ -728,3 +728,3 @@ import { Shader, Layer, Camera, PrimitiveMesh, MeshRenderer, BaseMaterial, BackgroundMode, Texture2D, RenderTarget, Component, Logger, AssetType, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Animator, SkinnedMeshRenderer } from 'oasis-engine'; | ||
this._setAnimationPromise = this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
var res, animations, animator, animatorController, layer, animatorStateMachine; | ||
var res, animations, animator, animatorController, layer, animatorStateMachine, clip, animatorState; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
@@ -753,13 +753,11 @@ while (1) { | ||
if (animations) { | ||
animations.forEach(function (clip) { | ||
var animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; | ||
}); | ||
} // @todo adapter updateAnimation | ||
clip = animations[0]; | ||
animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; // @todo adapter updateAnimation | ||
animator.speed = 1; | ||
animator.crossFade(clip.name, 0.3 / clip.length); | ||
} | ||
animator.speed = 1; | ||
animator.play(animations[0].name); | ||
case 15: | ||
case 13: | ||
case "end": | ||
@@ -788,4 +786,4 @@ return _context12.stop(); | ||
/** | ||
* Get time duration of animation clip by name. | ||
* @param clipName The name of the animation clip. | ||
* Get time duration of animation by glTF url. | ||
* @param url - The url of animation glTF file. | ||
* @returns The time duration in seconds. | ||
@@ -795,16 +793,36 @@ */ | ||
_proto.getAnimationDuration = function getAnimationDuration(clipName) { | ||
if (this._animationClips) { | ||
var clip = this._animationClips.find(function (_ref7) { | ||
var name = _ref7.name; | ||
return name === clipName; | ||
}); | ||
_proto.getAnimationDuration = | ||
/*#__PURE__*/ | ||
function () { | ||
var _getAnimationDuration = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(url) { | ||
var res, animations; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
_context14.next = 2; | ||
return this.engine.resourceManager.load({ | ||
type: AssetType.Prefab, | ||
url: url | ||
}); | ||
if (clip) { | ||
return clip.length; | ||
} | ||
case 2: | ||
res = _context14.sent; | ||
animations = res.animations; | ||
return _context14.abrupt("return", animations[0].length); | ||
case 5: | ||
case "end": | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
})); | ||
function getAnimationDuration(_x8) { | ||
return _getAnimationDuration.apply(this, arguments); | ||
} | ||
return 0; | ||
} | ||
return getAnimationDuration; | ||
}() | ||
/** | ||
@@ -820,10 +838,10 @@ * @override | ||
_proto._replaceModel = /*#__PURE__*/function () { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(modelUrl) { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, renderers, rendererIndex, renderer, material, skinRenderers, _rendererIndex, _renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
_context14.next = 2; | ||
_context15.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -835,3 +853,3 @@ type: AssetType.Prefab, | ||
case 2: | ||
res = _context14.sent; | ||
res = _context15.sent; | ||
@@ -895,9 +913,9 @@ this._destroyLastGLTF(); | ||
case "end": | ||
return _context14.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
}, _callee15, this); | ||
})); | ||
function _replaceModel(_x8) { | ||
function _replaceModel(_x9) { | ||
return _replaceModel3.apply(this, arguments); | ||
@@ -910,9 +928,9 @@ } | ||
_proto._loadModel = /*#__PURE__*/function () { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(url) { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(url) { | ||
var res, defaultSceneRoot; | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context15.next = 2; | ||
_context16.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -924,15 +942,15 @@ type: AssetType.Prefab, | ||
case 2: | ||
res = _context15.sent; | ||
res = _context16.sent; | ||
defaultSceneRoot = res.defaultSceneRoot; | ||
return _context15.abrupt("return", defaultSceneRoot.clone()); | ||
return _context16.abrupt("return", defaultSceneRoot.clone()); | ||
case 5: | ||
case "end": | ||
return _context15.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee15, this); | ||
}, _callee16, this); | ||
})); | ||
function _loadModel(_x9) { | ||
function _loadModel(_x10) { | ||
return _loadModel2.apply(this, arguments); | ||
@@ -1034,8 +1052,8 @@ } | ||
if (this._setModelPromise) { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
var json, index, _json$index, name, value; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
@@ -1056,6 +1074,6 @@ try { | ||
case "end": | ||
return _context16.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee16); | ||
}, _callee17); | ||
}))); | ||
@@ -1062,0 +1080,0 @@ } |
@@ -732,3 +732,3 @@ 'use strict'; | ||
this._setAnimationPromise = this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
var res, animations, animator, animatorController, layer, animatorStateMachine; | ||
var res, animations, animator, animatorController, layer, animatorStateMachine, clip, animatorState; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
@@ -757,13 +757,11 @@ while (1) { | ||
if (animations) { | ||
animations.forEach(function (clip) { | ||
var animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; | ||
}); | ||
} // @todo adapter updateAnimation | ||
clip = animations[0]; | ||
animatorState = animatorStateMachine.addState(clip.name); | ||
animatorState.clip = clip; // @todo adapter updateAnimation | ||
animator.speed = 1; | ||
animator.crossFade(clip.name, 0.3 / clip.length); | ||
} | ||
animator.speed = 1; | ||
animator.play(animations[0].name); | ||
case 15: | ||
case 13: | ||
case "end": | ||
@@ -792,4 +790,4 @@ return _context12.stop(); | ||
/** | ||
* Get time duration of animation clip by name. | ||
* @param clipName The name of the animation clip. | ||
* Get time duration of animation by glTF url. | ||
* @param url - The url of animation glTF file. | ||
* @returns The time duration in seconds. | ||
@@ -799,16 +797,36 @@ */ | ||
_proto.getAnimationDuration = function getAnimationDuration(clipName) { | ||
if (this._animationClips) { | ||
var clip = this._animationClips.find(function (_ref7) { | ||
var name = _ref7.name; | ||
return name === clipName; | ||
}); | ||
_proto.getAnimationDuration = | ||
/*#__PURE__*/ | ||
function () { | ||
var _getAnimationDuration = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(url) { | ||
var res, animations; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
_context14.next = 2; | ||
return this.engine.resourceManager.load({ | ||
type: miniprogram.AssetType.Prefab, | ||
url: url | ||
}); | ||
if (clip) { | ||
return clip.length; | ||
} | ||
case 2: | ||
res = _context14.sent; | ||
animations = res.animations; | ||
return _context14.abrupt("return", animations[0].length); | ||
case 5: | ||
case "end": | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
})); | ||
function getAnimationDuration(_x8) { | ||
return _getAnimationDuration.apply(this, arguments); | ||
} | ||
return 0; | ||
} | ||
return getAnimationDuration; | ||
}() | ||
/** | ||
@@ -824,10 +842,10 @@ * @override | ||
_proto._replaceModel = /*#__PURE__*/function () { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(modelUrl) { | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, renderers, rendererIndex, renderer, material, skinRenderers, _rendererIndex, _renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
_context14.next = 2; | ||
_context15.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -839,3 +857,3 @@ type: miniprogram.AssetType.Prefab, | ||
case 2: | ||
res = _context14.sent; | ||
res = _context15.sent; | ||
@@ -899,9 +917,9 @@ this._destroyLastGLTF(); | ||
case "end": | ||
return _context14.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee14, this); | ||
}, _callee15, this); | ||
})); | ||
function _replaceModel(_x8) { | ||
function _replaceModel(_x9) { | ||
return _replaceModel3.apply(this, arguments); | ||
@@ -914,9 +932,9 @@ } | ||
_proto._loadModel = /*#__PURE__*/function () { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(url) { | ||
var _loadModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(url) { | ||
var res, defaultSceneRoot; | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context15.next = 2; | ||
_context16.next = 2; | ||
return this.engine.resourceManager.load({ | ||
@@ -928,15 +946,15 @@ type: miniprogram.AssetType.Prefab, | ||
case 2: | ||
res = _context15.sent; | ||
res = _context16.sent; | ||
defaultSceneRoot = res.defaultSceneRoot; | ||
return _context15.abrupt("return", defaultSceneRoot.clone()); | ||
return _context16.abrupt("return", defaultSceneRoot.clone()); | ||
case 5: | ||
case "end": | ||
return _context15.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee15, this); | ||
}, _callee16, this); | ||
})); | ||
function _loadModel(_x9) { | ||
function _loadModel(_x10) { | ||
return _loadModel2.apply(this, arguments); | ||
@@ -1038,8 +1056,8 @@ } | ||
if (this._setModelPromise) { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
var json, index, _json$index, name, value; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
@@ -1060,6 +1078,6 @@ try { | ||
case "end": | ||
return _context16.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee16); | ||
}, _callee17); | ||
}))); | ||
@@ -1066,0 +1084,0 @@ } |
{ | ||
"version": "0.8.0-beta.2", | ||
"version": "0.8.0-beta.3", | ||
"name": "@oasis-engine/ark", | ||
@@ -4,0 +4,0 @@ "browser": "dist/index.browser.js", |
@@ -142,7 +142,7 @@ import { Animator, Component } from "oasis-engine"; | ||
/** | ||
* Get time duration of animation clip by name. | ||
* @param clipName The name of the animation clip. | ||
* Get time duration of animation by glTF url. | ||
* @param url - The url of animation glTF file. | ||
* @returns The time duration in seconds. | ||
*/ | ||
getAnimationDuration(clipName: string): number; | ||
getAnimationDuration(url: string): Promise<number>; | ||
/** | ||
@@ -149,0 +149,0 @@ * @override |
122461
3161