@oasis-engine/ark
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -185,4 +185,3 @@ (function (global, factory) { | ||
_this._animationClips = void 0; | ||
_this._blendShapeWeights = void 0; | ||
_this._blendShapeNameMap = void 0; | ||
_this._bsRenderers = void 0; | ||
var mapping = entity.createChild("uvMapping"); | ||
@@ -194,2 +193,21 @@ _this._uvMapping = mapping.addComponent(UVMapping); | ||
/** | ||
* Reset all blend shape | ||
*/ | ||
var _proto = ArkComponent.prototype; | ||
_proto.resetBlendShape = function resetBlendShape() { | ||
var renderers = this._bsRenderers; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
blendShapeWeights[weightIndex] = 0; | ||
} | ||
} | ||
} | ||
/** | ||
* Edit blendShape by name. | ||
@@ -199,15 +217,19 @@ * @param blendShapeName - the name of the blendShape. | ||
*/ | ||
; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var renderers = this._bsRenderers; | ||
var _proto = ArkComponent.prototype; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
this._blendShapeWeights[rendererIndex][weightIndex] = value; | ||
} else { | ||
oasisEngine.Logger.warn("no blendShape: " + blendShapeName + " in current model"); | ||
if (bsName === blendShapeName) { | ||
blendShapeWeights[weightIndex] = value; | ||
} | ||
} | ||
} | ||
@@ -223,29 +245,26 @@ } | ||
_proto.getBlendShapeValue = function getBlendShapeValue(blendShapeName) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
var renderers = this._bsRenderers; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
return this._blendShapeWeights[rendererIndex][weightIndex]; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (bsName === blendShapeName) { | ||
return blendShapeWeights[weightIndex]; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Replace face and body color. | ||
* @param roughness - roughness. | ||
* @param baseColor - base Color. | ||
* @param emissiveColor - emissive Color . | ||
*/ | ||
; | ||
_proto.replaceSkinColor = function replaceSkinColor(roughness, baseColor, emissiveColor) { | ||
var material = this._faceMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
material = this._bodyMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
_proto.replaceSkinColor = function replaceSkinColor(baseColor) { | ||
this._faceMaterial.baseColor = this._bodyMaterial.baseColor = baseColor; | ||
} | ||
@@ -825,3 +844,3 @@ /** | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights, mesh, weightIndex, weightLength, bsName; | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
@@ -884,21 +903,7 @@ while (1) { | ||
if (blendShapeWeights) { | ||
if (!this._blendShapeWeights) { | ||
this._blendShapeWeights = {}; | ||
if (!this._bsRenderers) { | ||
this._bsRenderers = []; | ||
} | ||
this._blendShapeWeights[rendererIndex] = blendShapeWeights; | ||
mesh = renderer.mesh; | ||
for (weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (!this._blendShapeNameMap) { | ||
this._blendShapeNameMap = {}; | ||
} | ||
this._blendShapeNameMap[bsName] = { | ||
rendererIndex: rendererIndex, | ||
weightIndex: weightIndex | ||
}; | ||
} | ||
this._bsRenderers.push(renderer); | ||
} | ||
@@ -969,4 +974,3 @@ } // init replace slot | ||
this._animationClips = null; | ||
this._blendShapeWeights = null; | ||
this._blendShapeNameMap = null; | ||
this._bsRenderers = null; | ||
}; | ||
@@ -1093,5 +1097,13 @@ | ||
var nameList = []; | ||
var renderers = this._bsRenderers; | ||
for (var name in this._blendShapeNameMap) { | ||
nameList.push(name); | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
nameList.push(bsName); | ||
} | ||
} | ||
@@ -1098,0 +1110,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Shader, Layer, Camera, PrimitiveMesh, MeshRenderer, BaseMaterial, Texture2D, RenderTarget, Component, Parser, Logger, AssetType, SkinnedMeshRenderer, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Animator } from 'oasis-engine'; | ||
import { Shader, Layer, Camera, PrimitiveMesh, MeshRenderer, BaseMaterial, Texture2D, RenderTarget, Component, Parser, AssetType, Logger, SkinnedMeshRenderer, AnimatorController, AnimatorControllerLayer, AnimatorStateMachine, Animator } from 'oasis-engine'; | ||
@@ -181,4 +181,3 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
_this._animationClips = void 0; | ||
_this._blendShapeWeights = void 0; | ||
_this._blendShapeNameMap = void 0; | ||
_this._bsRenderers = void 0; | ||
var mapping = entity.createChild("uvMapping"); | ||
@@ -190,2 +189,21 @@ _this._uvMapping = mapping.addComponent(UVMapping); | ||
/** | ||
* Reset all blend shape | ||
*/ | ||
var _proto = ArkComponent.prototype; | ||
_proto.resetBlendShape = function resetBlendShape() { | ||
var renderers = this._bsRenderers; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
blendShapeWeights[weightIndex] = 0; | ||
} | ||
} | ||
} | ||
/** | ||
* Edit blendShape by name. | ||
@@ -195,15 +213,19 @@ * @param blendShapeName - the name of the blendShape. | ||
*/ | ||
; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var renderers = this._bsRenderers; | ||
var _proto = ArkComponent.prototype; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
this._blendShapeWeights[rendererIndex][weightIndex] = value; | ||
} else { | ||
Logger.warn("no blendShape: " + blendShapeName + " in current model"); | ||
if (bsName === blendShapeName) { | ||
blendShapeWeights[weightIndex] = value; | ||
} | ||
} | ||
} | ||
@@ -219,29 +241,26 @@ } | ||
_proto.getBlendShapeValue = function getBlendShapeValue(blendShapeName) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
var renderers = this._bsRenderers; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
return this._blendShapeWeights[rendererIndex][weightIndex]; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (bsName === blendShapeName) { | ||
return blendShapeWeights[weightIndex]; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Replace face and body color. | ||
* @param roughness - roughness. | ||
* @param baseColor - base Color. | ||
* @param emissiveColor - emissive Color . | ||
*/ | ||
; | ||
_proto.replaceSkinColor = function replaceSkinColor(roughness, baseColor, emissiveColor) { | ||
var material = this._faceMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
material = this._bodyMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
_proto.replaceSkinColor = function replaceSkinColor(baseColor) { | ||
this._faceMaterial.baseColor = this._bodyMaterial.baseColor = baseColor; | ||
} | ||
@@ -821,3 +840,3 @@ /** | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights, mesh, weightIndex, weightLength, bsName; | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
@@ -880,21 +899,7 @@ while (1) { | ||
if (blendShapeWeights) { | ||
if (!this._blendShapeWeights) { | ||
this._blendShapeWeights = {}; | ||
if (!this._bsRenderers) { | ||
this._bsRenderers = []; | ||
} | ||
this._blendShapeWeights[rendererIndex] = blendShapeWeights; | ||
mesh = renderer.mesh; | ||
for (weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (!this._blendShapeNameMap) { | ||
this._blendShapeNameMap = {}; | ||
} | ||
this._blendShapeNameMap[bsName] = { | ||
rendererIndex: rendererIndex, | ||
weightIndex: weightIndex | ||
}; | ||
} | ||
this._bsRenderers.push(renderer); | ||
} | ||
@@ -965,4 +970,3 @@ } // init replace slot | ||
this._animationClips = null; | ||
this._blendShapeWeights = null; | ||
this._blendShapeNameMap = null; | ||
this._bsRenderers = null; | ||
}; | ||
@@ -1089,5 +1093,13 @@ | ||
var nameList = []; | ||
var renderers = this._bsRenderers; | ||
for (var name in this._blendShapeNameMap) { | ||
nameList.push(name); | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
nameList.push(bsName); | ||
} | ||
} | ||
@@ -1094,0 +1106,0 @@ |
@@ -185,4 +185,3 @@ 'use strict'; | ||
_this._animationClips = void 0; | ||
_this._blendShapeWeights = void 0; | ||
_this._blendShapeNameMap = void 0; | ||
_this._bsRenderers = void 0; | ||
var mapping = entity.createChild("uvMapping"); | ||
@@ -194,2 +193,21 @@ _this._uvMapping = mapping.addComponent(UVMapping); | ||
/** | ||
* Reset all blend shape | ||
*/ | ||
var _proto = ArkComponent.prototype; | ||
_proto.resetBlendShape = function resetBlendShape() { | ||
var renderers = this._bsRenderers; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
blendShapeWeights[weightIndex] = 0; | ||
} | ||
} | ||
} | ||
/** | ||
* Edit blendShape by name. | ||
@@ -199,15 +217,19 @@ * @param blendShapeName - the name of the blendShape. | ||
*/ | ||
; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var renderers = this._bsRenderers; | ||
var _proto = ArkComponent.prototype; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
_proto.editBlendShape = function editBlendShape(blendShapeName, value) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
this._blendShapeWeights[rendererIndex][weightIndex] = value; | ||
} else { | ||
miniprogram.Logger.warn("no blendShape: " + blendShapeName + " in current model"); | ||
if (bsName === blendShapeName) { | ||
blendShapeWeights[weightIndex] = value; | ||
} | ||
} | ||
} | ||
@@ -223,29 +245,26 @@ } | ||
_proto.getBlendShapeValue = function getBlendShapeValue(blendShapeName) { | ||
var info = this._blendShapeNameMap && this._blendShapeNameMap[blendShapeName]; | ||
var renderers = this._bsRenderers; | ||
if (info) { | ||
var rendererIndex = info.rendererIndex, | ||
weightIndex = info.weightIndex; | ||
return this._blendShapeWeights[rendererIndex][weightIndex]; | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (bsName === blendShapeName) { | ||
return blendShapeWeights[weightIndex]; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Replace face and body color. | ||
* @param roughness - roughness. | ||
* @param baseColor - base Color. | ||
* @param emissiveColor - emissive Color . | ||
*/ | ||
; | ||
_proto.replaceSkinColor = function replaceSkinColor(roughness, baseColor, emissiveColor) { | ||
var material = this._faceMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
material = this._bodyMaterial; | ||
material.roughness = roughness; | ||
material.baseColor = baseColor; | ||
material.emissiveColor = emissiveColor; | ||
_proto.replaceSkinColor = function replaceSkinColor(baseColor) { | ||
this._faceMaterial.baseColor = this._bodyMaterial.baseColor = baseColor; | ||
} | ||
@@ -825,3 +844,3 @@ /** | ||
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(modelUrl) { | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights, mesh, weightIndex, weightLength, bsName; | ||
var res, defaultSceneRoot, animations, clone, i, n, material, renderers, rendererIndex, rendererLength, renderer, blendShapeWeights; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
@@ -884,21 +903,7 @@ while (1) { | ||
if (blendShapeWeights) { | ||
if (!this._blendShapeWeights) { | ||
this._blendShapeWeights = {}; | ||
if (!this._bsRenderers) { | ||
this._bsRenderers = []; | ||
} | ||
this._blendShapeWeights[rendererIndex] = blendShapeWeights; | ||
mesh = renderer.mesh; | ||
for (weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
if (!this._blendShapeNameMap) { | ||
this._blendShapeNameMap = {}; | ||
} | ||
this._blendShapeNameMap[bsName] = { | ||
rendererIndex: rendererIndex, | ||
weightIndex: weightIndex | ||
}; | ||
} | ||
this._bsRenderers.push(renderer); | ||
} | ||
@@ -969,4 +974,3 @@ } // init replace slot | ||
this._animationClips = null; | ||
this._blendShapeWeights = null; | ||
this._blendShapeNameMap = null; | ||
this._bsRenderers = null; | ||
}; | ||
@@ -1093,5 +1097,13 @@ | ||
var nameList = []; | ||
var renderers = this._bsRenderers; | ||
for (var name in this._blendShapeNameMap) { | ||
nameList.push(name); | ||
for (var rendererIndex in renderers) { | ||
var renderer = renderers[rendererIndex]; | ||
var blendShapeWeights = renderer.blendShapeWeights; | ||
var mesh = renderer.mesh; | ||
for (var weightIndex = 0, weightLength = blendShapeWeights.length; weightIndex < weightLength; weightIndex++) { | ||
var bsName = mesh.getBlendShapeName ? mesh.getBlendShapeName(weightIndex) : weightIndex + ""; | ||
nameList.push(bsName); | ||
} | ||
} | ||
@@ -1098,0 +1110,0 @@ |
{ | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"name": "@oasis-engine/ark", | ||
@@ -4,0 +4,0 @@ "browser": "dist/index.browser.js", |
@@ -26,4 +26,3 @@ import { Animator, Color, Component, Entity } from "oasis-engine"; | ||
private _animationClips; | ||
private _blendShapeWeights; | ||
private _blendShapeNameMap; | ||
private _bsRenderers; | ||
/** | ||
@@ -69,2 +68,6 @@ * ------------- begin: editor config ------------- | ||
/** | ||
* Reset all blend shape | ||
*/ | ||
resetBlendShape(): void; | ||
/** | ||
* Edit blendShape by name. | ||
@@ -83,7 +86,5 @@ * @param blendShapeName - the name of the blendShape. | ||
* Replace face and body color. | ||
* @param roughness - roughness. | ||
* @param baseColor - base Color. | ||
* @param emissiveColor - emissive Color . | ||
*/ | ||
replaceSkinColor(roughness: number, baseColor: Color, emissiveColor: Color): void; | ||
replaceSkinColor(baseColor: Color): void; | ||
/** | ||
@@ -90,0 +91,0 @@ * Replace 3D Model by glTF url. |
116165
2988