wgge 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ import Model3dLoader from "./loader/Model3dLoader";
8
8
  import SpriteLoader from "./loader/SpriteLoader";
9
9
  import NodeWithEvents from "../../../core/model/event/NodeWithEvents";
10
10
  import StringHelper from "../../../core/helper/StringHelper";
11
+ import Model3dAnimationLoader from "./loader/Model3dAnimationLoader";
11
12
 
12
13
  const ASSET_TYPE_LOADERS = {
13
14
  'aud': AudioLoader,
@@ -15,6 +16,7 @@ const ASSET_TYPE_LOADERS = {
15
16
  'glb': GlbLoader,
16
17
  'mat': MaterialLoader,
17
18
  'm3d': Model3dLoader,
19
+ 'm3a': Model3dAnimationLoader,
18
20
  'spr': SpriteLoader
19
21
  }
20
22
 
@@ -11,6 +11,7 @@ export default class MaterialLoader extends AssetLoader {
11
11
 
12
12
  const id = StringHelper.extractId(this.uri);
13
13
  const definition = this.assets.resources.materials.getById(id);
14
+
14
15
  if (!definition) {
15
16
  this.fail(`material ID ${this.uri} not found`);
16
17
  return;
@@ -0,0 +1,27 @@
1
+ import AssetLoader from "./AssetLoader";
2
+ import StringHelper from "../../../../core/helper/StringHelper";
3
+ import AnimationHelper from "../../../../core/animation/3d/AnimationHelper";
4
+ import * as SkeletonUtils from "three/examples/jsm/utils/SkeletonUtils";
5
+
6
+ /**
7
+ * Loads an AnimationHelper for 3d model
8
+ */
9
+ export default class Model3dAnimationLoader extends AssetLoader {
10
+
11
+ loadInternal() {
12
+
13
+ const id = StringHelper.extractId(this.uri);
14
+ const model = this.assets.resources.models3d.getById(id);
15
+
16
+ if (!model) {
17
+ this.fail(`3D model id ${id} (${this.uri}) not found!`);
18
+ return;
19
+ }
20
+
21
+ this.assets.getAsset(model.uri.get(), (gltf) => {
22
+ const anim = new AnimationHelper(SkeletonUtils.clone(gltf.scene), gltf.animations);
23
+ this.finish(anim);
24
+ });
25
+ }
26
+
27
+ }
@@ -12,7 +12,7 @@ export default class Model3dLoader extends AssetLoader {
12
12
  const model = this.assets.resources.models3d.getById(id);
13
13
 
14
14
  if (!model) {
15
- this.fail(`Model id ${id} not found!`);
15
+ this.fail(`3D model id ${id} (${this.uri}) not found!`);
16
16
  return;
17
17
  }
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgge",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Web GL Game Engine",
5
5
  "main": "index.js",
6
6
  "dependencies": {