1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00
This commit is contained in:
Kevin Levron 2020-09-18 17:08:28 +02:00
parent 27c22b4e20
commit eb74b5b54f
2 changed files with 65 additions and 8 deletions

View File

@ -57,14 +57,29 @@ I will try to rewrite some of my [WebGL demos](https://codepen.io/collection/AG
I first made a simple *Proof of Concept*, take a look at [Test1.vue](/src/components/Test1.vue) :
```html
<Renderer ref="renderer">
<Camera :position="{ z: 100 }"></Camera>
<LambertMaterial id="material"></LambertMaterial>
<Scene>
<PointLight :position="{ x: 0, y: 50, z: 50 }"></PointLight>
<Box ref="box" :size="10" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }" material="material"></Box>
</Scene>
</Renderer>
<template>
<Renderer ref="renderer">
<Camera :position="{ z: 100 }"></Camera>
<LambertMaterial id="material"></LambertMaterial>
<Scene>
<PointLight :position="{ y: 50, z: 50 }"></PointLight>
<Box ref="box" :size="10" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }" material="material"></Box>
</Scene>
</Renderer>
</template>
<script>
export default {
mounted() {
const renderer = this.$refs.renderer;
const box = this.$refs.box.mesh;
renderer.onBeforeRender(() => {
box.rotation.x += 0.01;
});
},
};
</script>
```
## InstancedMesh

42
src/plugin.js Normal file
View File

@ -0,0 +1,42 @@
import * as TROIS from './index.js';
export default {
install: (app) => {
const comps = [
'Camera',
'PerspectiveCamera',
'Renderer',
'Scene',
'BoxGeometry',
'SphereGeometry',
'AmbientLight',
'PointLight',
'SpotLight',
'BasicMaterial',
'LambertMaterial',
'PhongMaterial',
'PhysicalMaterial',
'ShaderMaterial',
'StandardMaterial',
'SubSurfaceMaterial',
'Box',
'InstancedMesh',
'Plane',
'Sphere',
'Text',
'BokehPass',
'EffectComposer',
'RenderPass',
'UnrealBloomPass',
];
comps.forEach(comp => {
app.component(comp, TROIS[comp]);
});
},
};