mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
wip
This commit is contained in:
parent
bc44c532e4
commit
b6a8727c3e
@ -1,18 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }">
|
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }">
|
||||||
<Camera :position="{ z: 200 }"></Camera>
|
<Camera :position="{ z: 250 }"></Camera>
|
||||||
<BasicMaterial id="material"></BasicMaterial>
|
<BasicMaterial id="material"></BasicMaterial>
|
||||||
<Scene>
|
<Scene>
|
||||||
<Text
|
<Text
|
||||||
text="TEST"
|
ref="text"
|
||||||
|
text="TroisJS"
|
||||||
font-src="helvetiker_regular.typeface.json"
|
font-src="helvetiker_regular.typeface.json"
|
||||||
material="material"
|
material="material"
|
||||||
align="center"
|
align="center"
|
||||||
|
@ready="anim"
|
||||||
></Text>
|
></Text>
|
||||||
</Scene>
|
</Scene>
|
||||||
</Renderer>
|
</Renderer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {};
|
export default {
|
||||||
|
methods: {
|
||||||
|
anim() {
|
||||||
|
console.log('anim');
|
||||||
|
this.$refs.renderer.onBeforeRender(() => {
|
||||||
|
this.$refs.text.mesh.rotation.x += 0.01;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -159,11 +159,13 @@ export default function useThree() {
|
|||||||
* remove listeners
|
* remove listeners
|
||||||
*/
|
*/
|
||||||
function dispose() {
|
function dispose() {
|
||||||
|
beforeRenderHandlers.splice(0);
|
||||||
window.removeEventListener('resize', onResize);
|
window.removeEventListener('resize', onResize);
|
||||||
if (obj.mouse_move_element) {
|
if (obj.mouse_move_element) {
|
||||||
obj.mouse_move_element.removeEventListener('mousemove', onMousemove);
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
src/export.js
Normal file
2
src/export.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './index.js';
|
||||||
|
export * from './plugin.js';
|
@ -3,6 +3,6 @@ export * from './geometries/index.js';
|
|||||||
export * from './lights/index.js';
|
export * from './lights/index.js';
|
||||||
export * from './materials/index.js';
|
export * from './materials/index.js';
|
||||||
export * from './meshes/index.js';
|
export * from './meshes/index.js';
|
||||||
export * from './tools.js';
|
|
||||||
|
|
||||||
export * from './effects/index.js';
|
export * from './effects/index.js';
|
||||||
|
|
||||||
|
export * from './tools.js';
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
|
import { TroisJSVuePlugin } from './plugin.js';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import TroisJSPlugin from './plugin.js';
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
app.use(TroisJSPlugin);
|
app.use(TroisJSVuePlugin);
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
@ -3,6 +3,7 @@ import { setFromProp } from '../tools.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['three', 'scene'],
|
inject: ['three', 'scene'],
|
||||||
|
emits: ['ready'],
|
||||||
props: {
|
props: {
|
||||||
material: String,
|
material: String,
|
||||||
position: Object,
|
position: Object,
|
||||||
@ -32,6 +33,7 @@ export default {
|
|||||||
this.mesh.castShadow = this.castShadow;
|
this.mesh.castShadow = this.castShadow;
|
||||||
this.mesh.receiveShadow = this.receiveShadow;
|
this.mesh.receiveShadow = this.receiveShadow;
|
||||||
this.scene.add(this.mesh);
|
this.scene.add(this.mesh);
|
||||||
|
this.$emit('ready');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as TROIS from './index.js';
|
import * as TROIS from './index.js';
|
||||||
|
|
||||||
export default {
|
export const TroisJSVuePlugin = {
|
||||||
install: (app) => {
|
install: (app) => {
|
||||||
const comps = [
|
const comps = [
|
||||||
'Camera',
|
'Camera',
|
||||||
|
Loading…
Reference in New Issue
Block a user