diff --git a/src/components/Test4.vue b/src/components/Test4.vue index c2d32a6..7308dcc 100644 --- a/src/components/Test4.vue +++ b/src/components/Test4.vue @@ -1,18 +1,29 @@ diff --git a/src/core/useThree.js b/src/core/useThree.js index df6426f..1b25357 100644 --- a/src/core/useThree.js +++ b/src/core/useThree.js @@ -159,11 +159,13 @@ export default function useThree() { * remove listeners */ function dispose() { + beforeRenderHandlers.splice(0); window.removeEventListener('resize', onResize); if (obj.mouse_move_element) { obj.mouse_move_element.removeEventListener('mousemove', onMousemove); - obj.mouse_move_element.removeEventListener('mouseleave', onMouseleave); + obj.mouse_move_element.removeEventListener('mouseleave', onMouseleave); } + if (obj.orbitCtrl) obj.orbitCtrl.dispose(); } /** diff --git a/src/export.js b/src/export.js new file mode 100644 index 0000000..e8cba66 --- /dev/null +++ b/src/export.js @@ -0,0 +1,2 @@ +export * from './index.js'; +export * from './plugin.js'; diff --git a/src/index.js b/src/index.js index e7ec967..cd2b756 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,6 @@ export * from './geometries/index.js'; export * from './lights/index.js'; export * from './materials/index.js'; export * from './meshes/index.js'; -export * from './tools.js'; - export * from './effects/index.js'; + +export * from './tools.js'; diff --git a/src/main.js b/src/main.js index bf6e537..c4fffe9 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,8 @@ import { createApp } from 'vue'; +import { TroisJSVuePlugin } from './plugin.js'; import App from './App.vue'; -import TroisJSPlugin from './plugin.js'; import './index.css'; const app = createApp(App); -app.use(TroisJSPlugin); +app.use(TroisJSVuePlugin); app.mount('#app'); diff --git a/src/meshes/Mesh.js b/src/meshes/Mesh.js index 29b236a..edede10 100644 --- a/src/meshes/Mesh.js +++ b/src/meshes/Mesh.js @@ -3,6 +3,7 @@ import { setFromProp } from '../tools.js'; export default { inject: ['three', 'scene'], + emits: ['ready'], props: { material: String, position: Object, @@ -32,6 +33,7 @@ export default { this.mesh.castShadow = this.castShadow; this.mesh.receiveShadow = this.receiveShadow; this.scene.add(this.mesh); + this.$emit('ready'); }, }, render() { diff --git a/src/plugin.js b/src/plugin.js index 53f3def..faa3613 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -1,6 +1,6 @@ import * as TROIS from './index.js'; -export default { +export const TroisJSVuePlugin = { install: (app) => { const comps = [ 'Camera',