spline-vue
Version:
Vue2/Vue3 component for Spline scenes.
2 lines (1 loc) • 2.44 kB
JavaScript
(function(i,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue-demi"),require("@splinetool/runtime")):typeof define=="function"&&define.amd?define(["vue-demi","@splinetool/runtime"],l):(i=typeof globalThis<"u"?globalThis:i||self,i["spline-vue"]=l(i.VueDemi,i.runtime))})(this,function(i,l){"use strict";const b=i.defineComponent({name:"Spline",props:{scene:{type:String,required:!0},styles:{type:Object,default:()=>({})},autoRender:{type:Boolean,default:!1},onLoad:Function,onMouseDown:Function,onMouseUp:Function,onMouseHover:Function,onKeyDown:Function,onKeyUp:Function,onStart:Function,onLookAt:Function,onFollow:Function,onWheel:Function},setup(e,r){const c=i.ref(!0),d=u=>c.value=u,s=i.ref();return i.watchPostEffect(u=>{var n;d(!0);let t;const _=[{name:"mouseDown",cb:e.onMouseDown},{name:"mouseUp",cb:e.onMouseUp},{name:"mouseHover",cb:e.onMouseHover},{name:"keyDown",cb:e.onKeyDown},{name:"keyUp",cb:e.onKeyUp},{name:"start",cb:e.onStart},{name:"lookAt",cb:e.onLookAt},{name:"follow",cb:e.onFollow},{name:"scroll",cb:e.onWheel}];s.value&&(t=new l.Application(s.value,{autoRender:(n=e.autoRender)!=null?n:!1}),(async()=>{var v;await t.load(e.scene);for(let f of _)f.cb&&t.addEventListener(f.name,f.cb);d(!1),(v=e.onLoad)==null||v.call(e,t)})()),u==null||u(()=>{for(let o of _)o.cb&&t.removeEventListener(o.name,o.cb);t==null||t.dispose()})}),{isLoading:c,canvasRef:s}}});var y=function(){var e=this,r=e.$createElement,c=e._self._c||r;return c("canvas",{ref:"canvasRef",style:Object.assign({display:e.isLoading?"none":"block"},e.styles)})},F=[];function w(e,r,c,d,s,u,t,_){var n=typeof e=="function"?e.options:e;r&&(n.render=r,n.staticRenderFns=c,n._compiled=!0),d&&(n.functional=!0),u&&(n._scopeId="data-v-"+u);var o;if(t?(o=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!a&&typeof __VUE_SSR_CONTEXT__<"u"&&(a=__VUE_SSR_CONTEXT__),s&&s.call(this,a),a&&a._registeredComponents&&a._registeredComponents.add(t)},n._ssrRegister=o):s&&(o=_?function(){s.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:s),o)if(n.functional){n._injectStyles=o;var v=n.render;n.render=function(S,h){return o.call(h),v(S,h)}}else{var f=n.beforeCreate;n.beforeCreate=f?[].concat(f,o):[o]}return{exports:e,options:n}}const m={};var R=w(b,y,F,!1,L,null,null,null);function L(e){for(let r in m)this[r]=m[r]}return function(){return R.exports}()});