Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oasis-engine/ark

Package Overview
Dependencies
Maintainers
9
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oasis-engine/ark - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

207

dist/index.browser.js

@@ -118,5 +118,3 @@ (function (global, factory) {

function () {
var _replaceModel = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(modelUrl) {
var res, defaultSceneRoot, animations, clone, animator, i, length, renderers, _i, _length, blendShapeWeights;
var _replaceModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(modelUrl) {
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -126,65 +124,11 @@ while (1) {

case 0:
if (!this._setModelPromise) {
_context.next = 4;
break;
}
_context.next = 3;
return this._setModelPromise;
case 3:
this._destroyGLTF();
case 4:
if (modelUrl) {
_context.next = 6;
break;
this._setModelPromise = this._replaceModel(modelUrl);
} else {
this._destroyLastGLTF();
}
return _context.abrupt("return");
return _context.abrupt("return", this.onReady);
case 6:
this._setModelPromise = this.engine.resourceManager.load({
type: oasisEngine.AssetType.Prefab,
url: modelUrl
});
_context.next = 9;
return this._setModelPromise;
case 9:
res = _context.sent;
defaultSceneRoot = res.defaultSceneRoot, animations = res.animations;
clone = defaultSceneRoot.clone();
this.entity.addChild(clone);
this._modelEntity = clone; // animation
animator = clone.getComponent(oasisEngine.Animator);
this._animator = animator;
this._animationNameList.length = 0;
if (animations) {
for (i = 0, length = animations.length; i < length; i++) {
this._animationNameList[i] = animations[i].name;
}
} // blendshape
renderers = [];
clone.getComponentsIncludeChildren(oasisEngine.SkinnedMeshRenderer, renderers);
this._blendShapeWeights.length = 0;
for (_i = 0, _length = renderers.length; _i < _length; _i++) {
blendShapeWeights = renderers[_i].blendShapeWeights;
if (blendShapeWeights) {
this._blendShapeWeights.push(blendShapeWeights);
}
} // init replace slot
this._hairEntity = this._modelEntity.findByName("HumanNormal_Head_Hair_00");
this._eyeEntity = this._modelEntity.findByName("HumanNormal_Head_Eyes_00");
this._eyebrowEntity = this._modelEntity.findByName("HumanNormal_Head_Eyebrow_00");
case 25:
case 2:
case "end":

@@ -198,3 +142,3 @@ return _context.stop();

function replaceModel(_x) {
return _replaceModel.apply(this, arguments);
return _replaceModel2.apply(this, arguments);
}

@@ -347,14 +291,88 @@

return 0;
}
/**
* @override
*/
;
_proto._onDestroy = function _onDestroy() {
this.replaceModel(null);
};
_proto._destroyGLTF = function _destroyGLTF() {
_proto._replaceModel = /*#__PURE__*/function () {
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(modelUrl) {
var res, defaultSceneRoot, animations, clone, animator, i, length, renderers, _i, _length, blendShapeWeights;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return this.engine.resourceManager.load({
type: oasisEngine.AssetType.Prefab,
url: modelUrl
});
case 2:
res = _context4.sent;
this._destroyLastGLTF();
defaultSceneRoot = res.defaultSceneRoot, animations = res.animations;
clone = defaultSceneRoot.clone();
this.entity.addChild(clone);
this._modelEntity = clone; // animation
animator = clone.getComponent(oasisEngine.Animator);
this._animator = animator;
if (animations) {
for (i = 0, length = animations.length; i < length; i++) {
this._animationNameList[i] = animations[i].name;
}
} // blendshape
renderers = [];
clone.getComponentsIncludeChildren(oasisEngine.SkinnedMeshRenderer, renderers);
for (_i = 0, _length = renderers.length; _i < _length; _i++) {
blendShapeWeights = renderers[_i].blendShapeWeights;
if (blendShapeWeights) {
this._blendShapeWeights.push(blendShapeWeights);
}
} // init replace slot
this._hairEntity = this._modelEntity.findByName("HumanNormal_Head_Hair_00");
this._eyeEntity = this._modelEntity.findByName("HumanNormal_Head_Eyes_00");
this._eyebrowEntity = this._modelEntity.findByName("HumanNormal_Head_Eyebrow_00");
case 17:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function _replaceModel(_x4) {
return _replaceModel3.apply(this, arguments);
}
return _replaceModel;
}();
_proto._destroyLastGLTF = function _destroyLastGLTF() {
this._modelEntity && this._modelEntity.destroy();
this._modelEntity = null;
this._setModelPromise = null;
this._hairEntity = null;
this._eyeEntity = null;
this._eyebrowEntity = null;
this._animator = null;
this._animationNameList.length = 0;
this._blendShapeWeights.length = 0;
};
_proto._onDestroy = function _onDestroy() {
this.replaceModel(null);
};
_createClass(ArkComponent, [{

@@ -371,20 +389,20 @@ key: "eyeUrl",

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:
_this3._eyeEntity && _this3._eyeEntity.destroy();
_context4.next = 3;
_context5.next = 3;
return _this3.replaceComponent(url);
case 3:
_this3._eyeEntity = _context4.sent;
_this3._eyeEntity = _context5.sent;
case 4:
case "end":
return _context4.stop();
return _context5.stop();
}
}
}, _callee4);
}, _callee5);
})));

@@ -404,20 +422,20 @@ }

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
_this4._eyebrowEntity && _this4._eyebrowEntity.destroy();
_context5.next = 3;
_context6.next = 3;
return _this4.replaceComponent(url);
case 3:
_this4._eyebrowEntity = _context5.sent;
_this4._eyebrowEntity = _context6.sent;
case 4:
case "end":
return _context5.stop();
return _context6.stop();
}
}
}, _callee5);
}, _callee6);
})));

@@ -437,20 +455,20 @@ }

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context7.prev = _context7.next) {
case 0:
_this5._hairEntity && _this5._hairEntity.destroy();
_context6.next = 3;
_context7.next = 3;
return _this5.replaceComponent(url);
case 3:
_this5._hairEntity = _context6.sent;
_this5._hairEntity = _context7.sent;
case 4:
case "end":
return _context6.stop();
return _context7.stop();
}
}
}, _callee6);
}, _callee7);
})));

@@ -502,2 +520,11 @@ }

}
/**
* A hook to call back when loading is complete
*/
}, {
key: "onReady",
get: function get() {
return this._setModelPromise || Promise.resolve();
}
}]);

@@ -504,0 +531,0 @@

@@ -1,2 +0,2 @@

import { Parser, Component, Animator, SkinnedMeshRenderer, AssetType, MeshRenderer } from 'oasis-engine';
import { Parser, Component, MeshRenderer, SkinnedMeshRenderer, AssetType, Animator } from 'oasis-engine';

@@ -114,5 +114,3 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {

function () {
var _replaceModel = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(modelUrl) {
var res, defaultSceneRoot, animations, clone, animator, i, length, renderers, _i, _length, blendShapeWeights;
var _replaceModel2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(modelUrl) {
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -122,65 +120,11 @@ while (1) {

case 0:
if (!this._setModelPromise) {
_context.next = 4;
break;
}
_context.next = 3;
return this._setModelPromise;
case 3:
this._destroyGLTF();
case 4:
if (modelUrl) {
_context.next = 6;
break;
this._setModelPromise = this._replaceModel(modelUrl);
} else {
this._destroyLastGLTF();
}
return _context.abrupt("return");
return _context.abrupt("return", this.onReady);
case 6:
this._setModelPromise = this.engine.resourceManager.load({
type: AssetType.Prefab,
url: modelUrl
});
_context.next = 9;
return this._setModelPromise;
case 9:
res = _context.sent;
defaultSceneRoot = res.defaultSceneRoot, animations = res.animations;
clone = defaultSceneRoot.clone();
this.entity.addChild(clone);
this._modelEntity = clone; // animation
animator = clone.getComponent(Animator);
this._animator = animator;
this._animationNameList.length = 0;
if (animations) {
for (i = 0, length = animations.length; i < length; i++) {
this._animationNameList[i] = animations[i].name;
}
} // blendshape
renderers = [];
clone.getComponentsIncludeChildren(SkinnedMeshRenderer, renderers);
this._blendShapeWeights.length = 0;
for (_i = 0, _length = renderers.length; _i < _length; _i++) {
blendShapeWeights = renderers[_i].blendShapeWeights;
if (blendShapeWeights) {
this._blendShapeWeights.push(blendShapeWeights);
}
} // init replace slot
this._hairEntity = this._modelEntity.findByName("HumanNormal_Head_Hair_00");
this._eyeEntity = this._modelEntity.findByName("HumanNormal_Head_Eyes_00");
this._eyebrowEntity = this._modelEntity.findByName("HumanNormal_Head_Eyebrow_00");
case 25:
case 2:
case "end":

@@ -194,3 +138,3 @@ return _context.stop();

function replaceModel(_x) {
return _replaceModel.apply(this, arguments);
return _replaceModel2.apply(this, arguments);
}

@@ -343,14 +287,88 @@

return 0;
}
/**
* @override
*/
;
_proto._onDestroy = function _onDestroy() {
this.replaceModel(null);
};
_proto._destroyGLTF = function _destroyGLTF() {
_proto._replaceModel = /*#__PURE__*/function () {
var _replaceModel3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(modelUrl) {
var res, defaultSceneRoot, animations, clone, animator, i, length, renderers, _i, _length, blendShapeWeights;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return this.engine.resourceManager.load({
type: AssetType.Prefab,
url: modelUrl
});
case 2:
res = _context4.sent;
this._destroyLastGLTF();
defaultSceneRoot = res.defaultSceneRoot, animations = res.animations;
clone = defaultSceneRoot.clone();
this.entity.addChild(clone);
this._modelEntity = clone; // animation
animator = clone.getComponent(Animator);
this._animator = animator;
if (animations) {
for (i = 0, length = animations.length; i < length; i++) {
this._animationNameList[i] = animations[i].name;
}
} // blendshape
renderers = [];
clone.getComponentsIncludeChildren(SkinnedMeshRenderer, renderers);
for (_i = 0, _length = renderers.length; _i < _length; _i++) {
blendShapeWeights = renderers[_i].blendShapeWeights;
if (blendShapeWeights) {
this._blendShapeWeights.push(blendShapeWeights);
}
} // init replace slot
this._hairEntity = this._modelEntity.findByName("HumanNormal_Head_Hair_00");
this._eyeEntity = this._modelEntity.findByName("HumanNormal_Head_Eyes_00");
this._eyebrowEntity = this._modelEntity.findByName("HumanNormal_Head_Eyebrow_00");
case 17:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function _replaceModel(_x4) {
return _replaceModel3.apply(this, arguments);
}
return _replaceModel;
}();
_proto._destroyLastGLTF = function _destroyLastGLTF() {
this._modelEntity && this._modelEntity.destroy();
this._modelEntity = null;
this._setModelPromise = null;
this._hairEntity = null;
this._eyeEntity = null;
this._eyebrowEntity = null;
this._animator = null;
this._animationNameList.length = 0;
this._blendShapeWeights.length = 0;
};
_proto._onDestroy = function _onDestroy() {
this.replaceModel(null);
};
_createClass(ArkComponent, [{

@@ -367,20 +385,20 @@ key: "eyeUrl",

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:
_this3._eyeEntity && _this3._eyeEntity.destroy();
_context4.next = 3;
_context5.next = 3;
return _this3.replaceComponent(url);
case 3:
_this3._eyeEntity = _context4.sent;
_this3._eyeEntity = _context5.sent;
case 4:
case "end":
return _context4.stop();
return _context5.stop();
}
}
}, _callee4);
}, _callee5);
})));

@@ -400,20 +418,20 @@ }

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
_this4._eyebrowEntity && _this4._eyebrowEntity.destroy();
_context5.next = 3;
_context6.next = 3;
return _this4.replaceComponent(url);
case 3:
_this4._eyebrowEntity = _context5.sent;
_this4._eyebrowEntity = _context6.sent;
case 4:
case "end":
return _context5.stop();
return _context6.stop();
}
}
}, _callee5);
}, _callee6);
})));

@@ -433,20 +451,20 @@ }

if (url && this._setModelPromise) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
this._setModelPromise.then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context7.prev = _context7.next) {
case 0:
_this5._hairEntity && _this5._hairEntity.destroy();
_context6.next = 3;
_context7.next = 3;
return _this5.replaceComponent(url);
case 3:
_this5._hairEntity = _context6.sent;
_this5._hairEntity = _context7.sent;
case 4:
case "end":
return _context6.stop();
return _context7.stop();
}
}
}, _callee6);
}, _callee7);
})));

@@ -498,2 +516,11 @@ }

}
/**
* A hook to call back when loading is complete
*/
}, {
key: "onReady",
get: function get() {
return this._setModelPromise || Promise.resolve();
}
}]);

@@ -500,0 +527,0 @@

{
"version": "0.0.5",
"version": "0.0.6",
"name": "@oasis-engine/ark",

@@ -4,0 +4,0 @@ "browser": "dist/index.browser.js",

@@ -43,6 +43,8 @@ # Avatar Component

// use avatar capabilities in ArkComponent.
avatar.***();
avatar.***();
avatar.onReady.then(()=>{
avatar.***();
avatar.***();
})
};
};
```

@@ -49,0 +51,0 @@

@@ -39,2 +39,6 @@ import { Animator, Component, Entity } from "oasis-engine";

/**
* A hook to call back when loading is complete
*/
get onReady(): Promise<void>;
/**
* Replace 3D Model by glTF url.

@@ -68,5 +72,9 @@ * @param modelUrl - The url of 3D glTF file.

getFaceValueByIndex(rendererIndex: number, weightIndex: number): number;
_destroyGLTF(): void;
/**
* @override
*/
_onDestroy(): void;
private _replaceModel;
private _destroyLastGLTF;
}
export { ArkComponent };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc