diff --git a/src/components/liquid/LiquidPlane.js b/src/components/liquid/LiquidPlane.js index 37d29bf..dcb5505 100644 --- a/src/components/liquid/LiquidPlane.js +++ b/src/components/liquid/LiquidPlane.js @@ -1,7 +1,7 @@ import { DoubleSide, Mesh, MeshStandardMaterial, PlaneGeometry } from 'three'; import { watch } from 'vue'; import Object3D from '../../core/Object3D.js'; -import { bindProps } from '../../tools.js'; +import { bindProps } from '../../tools'; import LiquidEffect from './LiquidEffect.js'; export default { diff --git a/src/components/sliders/Slider1.vue b/src/components/sliders/Slider1.vue index 86836e2..fcb947e 100644 --- a/src/components/sliders/Slider1.vue +++ b/src/components/sliders/Slider1.vue @@ -14,7 +14,7 @@ import Camera from '../../core/PerspectiveCamera.js'; import Renderer from '../../core/Renderer.js'; import Scene from '../../core/Scene.js'; -import { lerp } from '../../tools.js'; +import { lerp } from '../../tools'; import AnimatedPlane from './AnimatedPlane.js'; import useTextures from '../../use/useTextures'; diff --git a/src/components/sliders/Slider2.vue b/src/components/sliders/Slider2.vue index be3d5ef..b277ba1 100644 --- a/src/components/sliders/Slider2.vue +++ b/src/components/sliders/Slider2.vue @@ -13,7 +13,7 @@ import OrthographicCamera from '../../core/OrthographicCamera.js'; import Renderer from '../../core/Renderer.js'; import Scene from '../../core/Scene.js'; -import { lerp, lerpv2 } from '../../tools.js'; +import { lerp, lerpv2 } from '../../tools'; import ZoomBlurImage from './ZoomBlurImage.js'; import useTextures from '../../use/useTextures.js'; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index ea83fd1..75570ea 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -1,5 +1,5 @@ import { watch } from 'vue'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools/index.js'; export default { name: 'Object3D', @@ -10,7 +10,9 @@ export default { rotation: { type: Object, default: { x: 0, y: 0, z: 0 } }, scale: { type: Object, default: { x: 1, y: 1, z: 1 } }, lookAt: { type: Object, default: null }, - onPointerEnter: { type: Function, default: null } + onPointerEnter: { type: Function, default: null }, + onPointerOver: { type: Function, default: null }, + onPointerLeave: { type: Function, default: null } }, // can't use setup because it will not be used in sub components // setup() {}, @@ -30,8 +32,8 @@ export default { if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z); watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z); }, { deep: true }); - if (this.onPointerEnter) { - this.three.onBeforeRender(this.raycastEnter) + if (this.onPointerEnter || this.onPointerOver || this.onPointerLeave) { + this.three.onBeforeRender(this.pointerHandler) } // find first viable parent @@ -49,7 +51,7 @@ export default { }, add(o) { this.o3d.add(o); }, remove(o) { this.o3d.remove(o); }, - raycastEnter() { + pointerHandler() { this.three.raycaster.setFromCamera(this.three.mouse, this.three.camera) const intersects = this.three.raycaster.intersectObjects([this.o3d]) if (intersects.length) { diff --git a/src/core/OrthographicCamera.js b/src/core/OrthographicCamera.js index f221491..c5bb443 100644 --- a/src/core/OrthographicCamera.js +++ b/src/core/OrthographicCamera.js @@ -1,6 +1,6 @@ import { OrthographicCamera } from 'three'; import { watch } from 'vue'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; import Camera from './Camera.js'; export default { diff --git a/src/core/PerspectiveCamera.js b/src/core/PerspectiveCamera.js index 0c818fa..0ece470 100644 --- a/src/core/PerspectiveCamera.js +++ b/src/core/PerspectiveCamera.js @@ -1,6 +1,6 @@ import { PerspectiveCamera } from 'three'; import { watch } from 'vue'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; import Camera from './Camera.js'; export default { diff --git a/src/effects/TiltShiftPass.js b/src/effects/TiltShiftPass.js index 7046969..bd6e404 100644 --- a/src/effects/TiltShiftPass.js +++ b/src/effects/TiltShiftPass.js @@ -3,7 +3,7 @@ import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { watch } from 'vue'; import EffectPass from './EffectPass.js'; import TiltShift from '../shaders/TiltShift.js'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { extends: EffectPass, diff --git a/src/effects/ZoomBlurPass.js b/src/effects/ZoomBlurPass.js index b492af5..24eb76a 100644 --- a/src/effects/ZoomBlurPass.js +++ b/src/effects/ZoomBlurPass.js @@ -1,7 +1,7 @@ import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import EffectPass from './EffectPass.js'; import ZoomBlur from '../shaders/ZoomBlur.js'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { extends: EffectPass, diff --git a/src/index.js b/src/index.js index c648fae..87dd77d 100644 --- a/src/index.js +++ b/src/index.js @@ -8,4 +8,4 @@ export * from './effects/index.js'; // export * from './components/index.js'; -export * from './tools.js'; +export * from './tools'; diff --git a/src/lights/Light.js b/src/lights/Light.js index 73dcf3c..d42dacd 100644 --- a/src/lights/Light.js +++ b/src/lights/Light.js @@ -1,6 +1,6 @@ import { watch } from 'vue'; import Object3D from '../core/Object3D.js'; -import { bindProp, setFromProp } from '../tools.js'; +import { bindProp, setFromProp } from '../tools'; export default { extends: Object3D, diff --git a/src/materials/BasicMaterial.js b/src/materials/BasicMaterial.js index 6a82eca..d0183a2 100644 --- a/src/materials/BasicMaterial.js +++ b/src/materials/BasicMaterial.js @@ -1,5 +1,5 @@ import { MeshBasicMaterial } from 'three'; -import { bindProps, propsValues } from '../tools.js'; +import { bindProps, propsValues } from '../tools'; import Material, { wireframeProps } from './Material'; export default { diff --git a/src/materials/LambertMaterial.js b/src/materials/LambertMaterial.js index 7e33e35..b29c605 100644 --- a/src/materials/LambertMaterial.js +++ b/src/materials/LambertMaterial.js @@ -1,5 +1,5 @@ import { MeshLambertMaterial } from 'three'; -import { bindProps, propsValues } from '../tools.js'; +import { bindProps, propsValues } from '../tools'; import Material, { wireframeProps } from './Material'; export default { diff --git a/src/materials/MatcapMaterial.js b/src/materials/MatcapMaterial.js index 6595aed..0f4349a 100644 --- a/src/materials/MatcapMaterial.js +++ b/src/materials/MatcapMaterial.js @@ -1,6 +1,6 @@ import { MeshMatcapMaterial, TextureLoader } from 'three'; // import { watch } from 'vue'; -import { propsValues, getMatcapUrl } from '../tools.js'; +import { propsValues, getMatcapUrl } from '../tools'; import Material from './Material'; export default { diff --git a/src/materials/PhongMaterial.js b/src/materials/PhongMaterial.js index 2a0258a..9585a96 100644 --- a/src/materials/PhongMaterial.js +++ b/src/materials/PhongMaterial.js @@ -1,6 +1,6 @@ import { MeshPhongMaterial } from 'three'; import { watch } from 'vue'; -import { bindProps, propsValues } from '../tools.js'; +import { bindProps, propsValues } from '../tools'; import Material, { wireframeProps } from './Material'; export default { diff --git a/src/materials/PhysicalMaterial.js b/src/materials/PhysicalMaterial.js index d8dca76..84edc6a 100644 --- a/src/materials/PhysicalMaterial.js +++ b/src/materials/PhysicalMaterial.js @@ -1,5 +1,5 @@ import { MeshPhysicalMaterial } from 'three'; -import { propsValues } from '../tools.js'; +import { propsValues } from '../tools'; import StandardMaterial from './StandardMaterial'; export default { diff --git a/src/materials/ShaderMaterial.js b/src/materials/ShaderMaterial.js index 1677b10..d9d14af 100644 --- a/src/materials/ShaderMaterial.js +++ b/src/materials/ShaderMaterial.js @@ -1,6 +1,6 @@ import { ShaderMaterial } from 'three'; import { watch } from 'vue'; -import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools.js'; +import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tools'; export default { inject: ['three', 'mesh'], diff --git a/src/materials/StandardMaterial.js b/src/materials/StandardMaterial.js index 1c39a0d..3e18406 100644 --- a/src/materials/StandardMaterial.js +++ b/src/materials/StandardMaterial.js @@ -1,6 +1,6 @@ import { MeshStandardMaterial } from 'three'; import { watch } from 'vue'; -import { bindProp, bindProps, propsValues } from '../tools.js'; +import { bindProp, bindProps, propsValues } from '../tools'; import Material, { wireframeProps } from './Material'; const props = { diff --git a/src/materials/Texture.js b/src/materials/Texture.js index 7797089..c7c3033 100644 --- a/src/materials/Texture.js +++ b/src/materials/Texture.js @@ -1,6 +1,6 @@ import { ClampToEdgeWrapping, LinearFilter, LinearMipmapLinearFilter, TextureLoader, UVMapping } from 'three'; import { watch } from 'vue'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { inject: ['material'], diff --git a/src/materials/ToonMaterial.js b/src/materials/ToonMaterial.js index f790edd..b87d4a1 100644 --- a/src/materials/ToonMaterial.js +++ b/src/materials/ToonMaterial.js @@ -1,5 +1,5 @@ import { MeshToonMaterial } from 'three'; -import { bindProps, propsValues } from '../tools.js'; +import { bindProps, propsValues } from '../tools'; import Material, { wireframeProps } from './Material'; export default { diff --git a/src/meshes/Gem.js b/src/meshes/Gem.js index 71f90f1..9d33be1 100644 --- a/src/meshes/Gem.js +++ b/src/meshes/Gem.js @@ -8,7 +8,7 @@ import { WebGLCubeRenderTarget, } from 'three'; import Mesh from './Mesh.js'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { extends: Mesh, diff --git a/src/meshes/InstancedMesh.js b/src/meshes/InstancedMesh.js index d038dd2..a5a0bca 100644 --- a/src/meshes/InstancedMesh.js +++ b/src/meshes/InstancedMesh.js @@ -1,6 +1,6 @@ import { InstancedMesh } from 'three'; import Object3D from '../core/Object3D.js'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { extends: Object3D, diff --git a/src/meshes/RefractionMesh.js b/src/meshes/RefractionMesh.js index 431a5f4..ce0a443 100644 --- a/src/meshes/RefractionMesh.js +++ b/src/meshes/RefractionMesh.js @@ -6,7 +6,7 @@ import { WebGLCubeRenderTarget, } from 'three'; import Mesh from './Mesh.js'; -import { bindProp } from '../tools.js'; +import { bindProp } from '../tools'; export default { extends: Mesh, diff --git a/src/tools.js b/src/tools/index.js similarity index 100% rename from src/tools.js rename to src/tools/index.js