mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
update examples
This commit is contained in:
parent
eb74b5b54f
commit
8eb6e0ec93
@ -11,17 +11,18 @@
|
|||||||
import Test1 from './components/Test1.vue';
|
import Test1 from './components/Test1.vue';
|
||||||
import Test2 from './components/Test2.vue';
|
import Test2 from './components/Test2.vue';
|
||||||
import Test3 from './components/Test3.vue';
|
import Test3 from './components/Test3.vue';
|
||||||
|
import Test4 from './components/Test4.vue';
|
||||||
import TestGLTF from './components/TestGLTF.vue';
|
import TestGLTF from './components/TestGLTF.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
Test1, Test2, Test3, TestGLTF,
|
Test1, Test2, Test3, Test4, TestGLTF,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tests: ['Test1', 'Test2', 'Test3', 'TestGLTF'],
|
tests: ['Test1', 'Test2', 'Test3', 'Test4', 'TestGLTF'],
|
||||||
test: 'Test2',
|
test: 'Test1',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,27 +3,14 @@
|
|||||||
<Camera :position="{ z: 100 }"></Camera>
|
<Camera :position="{ z: 100 }"></Camera>
|
||||||
<LambertMaterial id="material"></LambertMaterial>
|
<LambertMaterial id="material"></LambertMaterial>
|
||||||
<Scene>
|
<Scene>
|
||||||
<PointLight :position="{ x: 0, y: 50, z: 50 }"></PointLight>
|
<PointLight :position="{ y: 50, z: 50 }"></PointLight>
|
||||||
<Box ref="box" :size="10" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }" material="material"></Box>
|
<Box ref="box" :size="10" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }" material="material"></Box>
|
||||||
</Scene>
|
</Scene>
|
||||||
</Renderer>
|
</Renderer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
|
||||||
Renderer, Camera, Scene,
|
|
||||||
LambertMaterial,
|
|
||||||
PointLight,
|
|
||||||
Box,
|
|
||||||
} from '../index.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
Renderer, Camera, Scene,
|
|
||||||
LambertMaterial,
|
|
||||||
PointLight,
|
|
||||||
Box,
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const renderer = this.$refs.renderer;
|
const renderer = this.$refs.renderer;
|
||||||
const box = this.$refs.box.mesh;
|
const box = this.$refs.box.mesh;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }" mouse-move="body" :mouse-raycast="true">
|
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }" mouse-move="body" :mouse-raycast="true">
|
||||||
<Camera :position="{ z: 200 }"></Camera>
|
<Camera :position="{ z: 200 }"></Camera>
|
||||||
<StandardMaterial id="material" :transparent="true" :opacity="0.9" :metalness="0.8" :roughness="0.5"></StandardMaterial>
|
<StandardMaterial id="material" :transparent="true" :opacity="0.9" :metalness="0.8" :roughness="0.5"></StandardMaterial>
|
||||||
<Scene id="scene1" background="#000000">
|
<Scene>
|
||||||
<AmbientLight color="#808080"></AmbientLight>
|
<AmbientLight color="#808080"></AmbientLight>
|
||||||
<PointLight color="#ff6000"></PointLight>
|
<PointLight color="#ff6000"></PointLight>
|
||||||
<PointLight ref="light" color="#0060ff" :intensity="0.5"></PointLight>
|
<PointLight ref="light" color="#0060ff" :intensity="0.5"></PointLight>
|
||||||
@ -20,23 +20,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import { Object3D, MathUtils, Vector3 } from 'three';
|
import { Object3D, MathUtils, Vector3 } from 'three';
|
||||||
|
|
||||||
import {
|
|
||||||
Renderer, Camera, Scene, AmbientLight, PointLight,
|
|
||||||
StandardMaterial, InstancedMesh, BoxGeometry,
|
|
||||||
EffectComposer, RenderPass, UnrealBloomPass,
|
|
||||||
} from '../index.js';
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
randFloat: rnd,
|
randFloat: rnd,
|
||||||
randFloatSpread: rndFS,
|
randFloatSpread: rndFS,
|
||||||
} = MathUtils;
|
} = MathUtils;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
Renderer, Camera, Scene, AmbientLight, PointLight,
|
|
||||||
StandardMaterial, InstancedMesh, BoxGeometry,
|
|
||||||
EffectComposer, RenderPass, UnrealBloomPass,
|
|
||||||
},
|
|
||||||
setup() {
|
setup() {
|
||||||
const NUM_INSTANCES = 2000;
|
const NUM_INSTANCES = 2000;
|
||||||
const instances = [];
|
const instances = [];
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }" :shadow="true">
|
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }" :shadow="true">
|
||||||
<Camera :position="{ z: 100 }"></Camera>
|
<Camera :position="{ z: 100 }"></Camera>
|
||||||
<PhongMaterial id="material" color="#ffffff"></PhongMaterial>
|
<PhongMaterial id="material" color="#ffffff"></PhongMaterial>
|
||||||
<Scene id="scene1" background="#000000">
|
<Scene>
|
||||||
<SpotLight color="#ffffff" :intensity="0.5" :position="{ y: 150, z: 0 }" :cast-shadow="true" :shadow-map-size="{ width: 1024, height: 1024 }"></SpotLight>
|
<SpotLight color="#ffffff" :intensity="0.5" :position="{ y: 150, z: 0 }" :cast-shadow="true" :shadow-map-size="{ width: 1024, height: 1024 }"></SpotLight>
|
||||||
<SpotLight color="#ff0000" :intensity="0.5" :position="{ y: -150, z: 0 }" :cast-shadow="true" :shadow-map-size="{ width: 1024, height: 1024 }"></SpotLight>
|
<SpotLight color="#ff0000" :intensity="0.5" :position="{ y: -150, z: 0 }" :cast-shadow="true" :shadow-map-size="{ width: 1024, height: 1024 }"></SpotLight>
|
||||||
<InstancedMesh ref="imesh" material="material" :count="NUM_INSTANCES" :cast-shadow="true" :receive-shadow="true">
|
<InstancedMesh ref="imesh" material="material" :count="NUM_INSTANCES" :cast-shadow="true" :receive-shadow="true">
|
||||||
@ -19,18 +19,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { Object3D, MathUtils } from 'three';
|
import { Object3D, MathUtils } from 'three';
|
||||||
|
|
||||||
import {
|
|
||||||
Renderer, Camera, Scene, SpotLight,
|
|
||||||
PhongMaterial, InstancedMesh, SphereGeometry,
|
|
||||||
EffectComposer, RenderPass, UnrealBloomPass,
|
|
||||||
} from '../index.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
Renderer, Camera, Scene, SpotLight,
|
|
||||||
PhongMaterial, InstancedMesh, SphereGeometry,
|
|
||||||
EffectComposer, RenderPass, UnrealBloomPass,
|
|
||||||
},
|
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
NUM_INSTANCES: 500,
|
NUM_INSTANCES: 500,
|
||||||
|
18
src/components/Test4.vue
Normal file
18
src/components/Test4.vue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<Renderer ref="renderer" :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }">
|
||||||
|
<Camera :position="{ z: 200 }"></Camera>
|
||||||
|
<BasicMaterial id="material"></BasicMaterial>
|
||||||
|
<Scene>
|
||||||
|
<Text
|
||||||
|
text="TEST"
|
||||||
|
font-src="helvetiker_regular.typeface.json"
|
||||||
|
material="material"
|
||||||
|
align="center"
|
||||||
|
></Text>
|
||||||
|
</Scene>
|
||||||
|
</Renderer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {};
|
||||||
|
</script>
|
@ -1,6 +1,8 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
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.mount('#app');
|
app.mount('#app');
|
||||||
|
Loading…
Reference in New Issue
Block a user