1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

defineComponent for components (#10)

This commit is contained in:
Kevin Levron 2021-04-04 21:06:06 +02:00
parent d506b3333e
commit db5aca7538
8 changed files with 24 additions and 21 deletions

View File

@ -1,10 +1,10 @@
import { defineComponent, watch } from 'vue';
import { DoubleSide, Mesh, MeshStandardMaterial, PlaneGeometry } from 'three'; import { DoubleSide, Mesh, MeshStandardMaterial, PlaneGeometry } from 'three';
import { watch } from 'vue';
import Object3D from '../../core/Object3D.js'; import Object3D from '../../core/Object3D.js';
import { bindProps } from '../../tools'; import { bindProps } from '../../tools';
import LiquidEffect from './LiquidEffect.js'; import LiquidEffect from './LiquidEffect.js';
export default { export default defineComponent({
extends: Object3D, extends: Object3D,
props: { props: {
width: { type: Number, default: 10 }, width: { type: Number, default: 10 },
@ -51,4 +51,4 @@ export default {
this.liquidEffect.update(); this.liquidEffect.update();
}, },
}, },
}; });

View File

@ -1,9 +1,9 @@
import { defineComponent, watch } from 'vue';
import { DoubleSide, MeshBasicMaterial, PlaneGeometry } from 'three'; import { DoubleSide, MeshBasicMaterial, PlaneGeometry } from 'three';
import { watch } from 'vue';
import Image from '../../meshes/Image.js'; import Image from '../../meshes/Image.js';
import snoise2 from '../../glsl/snoise2.glsl.js'; import snoise2 from '../../glsl/snoise2.glsl.js';
export default { export default defineComponent({
extends: Image, extends: Image,
props: { props: {
widthSegments: { type: Number, default: 20 }, widthSegments: { type: Number, default: 20 },
@ -86,4 +86,4 @@ export default {
}, },
}, },
__hmrId: 'NoisyImage', __hmrId: 'NoisyImage',
}; });

View File

@ -1,10 +1,10 @@
import { defineComponent, watch } from 'vue';
import { ObjectSpaceNormalMap, ShaderMaterial, Vector2, WebGLRenderTarget } from 'three'; import { ObjectSpaceNormalMap, ShaderMaterial, Vector2, WebGLRenderTarget } from 'three';
import { Pass } from 'three/examples/jsm/postprocessing/Pass.js'; import { Pass } from 'three/examples/jsm/postprocessing/Pass.js';
import { watch } from 'vue';
import Plane from '../../meshes/Plane.js'; import Plane from '../../meshes/Plane.js';
import snoise3 from '../../glsl/snoise3.glsl.js'; import snoise3 from '../../glsl/snoise3.glsl.js';
export default { export default defineComponent({
extends: Plane, extends: Plane,
props: { props: {
timeCoef: { type: Number, default: 0.001 }, timeCoef: { type: Number, default: 0.001 },
@ -126,4 +126,4 @@ export default {
}, },
}, },
__hmrId: 'NoisyPlane', __hmrId: 'NoisyPlane',
}; });

View File

@ -1,8 +1,8 @@
import { watch } from 'vue'; import { defineComponent, watch } from 'vue';
import Sphere from '../../meshes/Sphere.js'; import Sphere from '../../meshes/Sphere.js';
import snoise4 from '../../glsl/snoise4.glsl.js'; import snoise4 from '../../glsl/snoise4.glsl.js';
export default { export default defineComponent({
extends: Sphere, extends: Sphere,
props: { props: {
radius: { type: Number, default: 20 }, radius: { type: Number, default: 20 },
@ -65,4 +65,4 @@ export default {
}, },
}, },
__hmrId: 'NoisySphere', __hmrId: 'NoisySphere',
}; });

View File

@ -1,8 +1,8 @@
import { watch } from 'vue'; import { defineComponent, watch } from 'vue';
import Text from '../../meshes/Text.js'; import Text from '../../meshes/Text.js';
import snoise2 from '../../glsl/snoise2.glsl.js'; import snoise2 from '../../glsl/snoise2.glsl.js';
export default { export default defineComponent({
extends: Text, extends: Text,
props: { props: {
timeCoef: { type: Number, default: 0.001 }, timeCoef: { type: Number, default: 0.001 },
@ -62,4 +62,4 @@ export default {
}, },
}, },
__hmrId: 'NoisyText', __hmrId: 'NoisyText',
}; });

View File

@ -7,6 +7,7 @@
</template> </template>
<script> <script>
import { defineComponent } from 'vue';
import { Object3D } from 'three'; import { Object3D } from 'three';
import { gsap, Power4 } from 'gsap'; import { gsap, Power4 } from 'gsap';
@ -18,7 +19,7 @@ import { lerp } from '../../tools';
import AnimatedPlane from './AnimatedPlane.js'; import AnimatedPlane from './AnimatedPlane.js';
import useTextures from '../../use/useTextures'; import useTextures from '../../use/useTextures';
export default { export default defineComponent({
components: { Camera, Renderer, Scene }, components: { Camera, Renderer, Scene },
props: { props: {
images: Array, images: Array,
@ -161,5 +162,5 @@ export default {
this.plane2.o3d.position.z = progress - 1; this.plane2.o3d.position.z = progress - 1;
}, },
}, },
}; });
</script> </script>

View File

@ -6,6 +6,7 @@
</template> </template>
<script> <script>
import { defineComponent } from 'vue';
import { Vector2 } from 'three'; import { Vector2 } from 'three';
import { gsap, Power4 } from 'gsap'; import { gsap, Power4 } from 'gsap';
@ -17,7 +18,7 @@ import { lerp, lerpv2 } from '../../tools';
import ZoomBlurImage from './ZoomBlurImage.js'; import ZoomBlurImage from './ZoomBlurImage.js';
import useTextures from '../../use/useTextures.js'; import useTextures from '../../use/useTextures.js';
export default { export default defineComponent({
components: { OrthographicCamera, Renderer, Scene }, components: { OrthographicCamera, Renderer, Scene },
props: { props: {
images: Array, images: Array,
@ -154,5 +155,5 @@ export default {
this.image2.uStrength.value = -1 + progress; this.image2.uStrength.value = -1 + progress;
}, },
}, },
}; });
</script> </script>

View File

@ -8,12 +8,13 @@
</template> </template>
<script> <script>
import { defineComponent } from 'vue';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import Camera from '../../core/PerspectiveCamera.js'; import Camera from '../../core/PerspectiveCamera.js';
import Renderer from '../../core/Renderer.js'; import Renderer from '../../core/Renderer.js';
import Scene from '../../core/Scene.js'; import Scene from '../../core/Scene.js';
export default { export default defineComponent({
components: { Camera, Renderer, Scene }, components: { Camera, Renderer, Scene },
props: { props: {
src: String, src: String,
@ -27,5 +28,5 @@ export default {
this.renderer.three.scene.add(gltf.scene); this.renderer.three.scene.add(gltf.scene);
}); });
}, },
}; });
</script> </script>