1 |
- !function e(i,t,n){function o(a,s){if(!t[a]){if(!i[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(r)return r(a,!0);var m=new Error("Cannot find module '"+a+"'");throw m.code="MODULE_NOT_FOUND",m}var d=t[a]={exports:{}};i[a][0].call(d.exports,function(e){var t=i[a][1][e];return o(t||e)},d,d.exports,e,i,t,n)}return t[a].exports}for(var r="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,i,t){AFRAME.registerComponent("three-model",e("./src/loaders/three-model"))},{"./src/loaders/three-model":2}],2:[function(e,i,t){i.exports={deprecated:!0,schema:{src:{type:"asset"},loader:{default:"object",oneOf:["object","json"]},enableAnimation:{default:!0},animation:{default:"__auto__"},animationDuration:{default:0},crossorigin:{default:""}},init:function(){this.model=null,this.mixer=null,console.warn("[three-model] Component is deprecated. Use json-model or object-model instead.")},update:function(e){e=e||{};var i,t=this.data;if(t.src)if(Object.keys(e).length){var n=this.model&&this.model.activeAction;if(t.animation!==e.animation)return n&&n.stop(),void this.playAnimation();n&&t.enableAnimation!==n.isRunning()&&(t.enableAnimation?this.playAnimation():n.stop()),n&&t.animationDuration&&n.setDuration(t.animationDuration)}else if(this.remove(),"object"===t.loader)i=new THREE.ObjectLoader,t.crossorigin&&i.setCrossOrigin(t.crossorigin),i.load(t.src,function(e){e.traverse(function(i){i instanceof THREE.SkinnedMesh&&(e=i)}),e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length),this.load(e)}.bind(this));else{if("json"!==t.loader)throw new Error('[three-model] Invalid mode "%s".',t.mode);i=new THREE.JSONLoader,t.crossorigin&&(i.crossOrigin=t.crossorigin),i.load(t.src,function(e,i){i.forEach(function(i){i.vertexColors=(e.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,i.skinning=!!(e.bones||[]).length,i.morphTargets=!!(e.morphTargets||[]).length,i.morphNormals=!!(e.morphNormals||[]).length});var t=(e.bones||[]).length?new THREE.SkinnedMesh(e,new THREE.MultiMaterial(i)):new THREE.Mesh(e,new THREE.MultiMaterial(i));this.load(t)}.bind(this))}else this.remove()},load:function(e){this.model=e,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"three",model:e}),this.data.enableAnimation&&this.playAnimation()},playAnimation:function(){var e,i=this.data,t=this.model.animations||this.model.geometry.animations||[];i.enableAnimation&&i.animation&&t.length&&((e="__auto__"===i.animation?t[0]:THREE.AnimationClip.findByName(t,i.animation))?(this.model.activeAction=this.mixer.clipAction(e,this.model),i.animationDuration&&this.model.activeAction.setDuration(i.animationDuration),this.model.activeAction.play()):console.error('[three-model] Animation "%s" not found.',i.animation))},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(e,i){this.mixer&&!isNaN(i)&&this.mixer.update(i/1e3)}}},{}]},{},[1]);
|