|
@@ -13,21 +13,16 @@ import {
|
|
|
ACESFilmicToneMapping,
|
|
|
CustomToneMapping,
|
|
|
} from 'three'
|
|
|
+import { TresCanvas } from '/@/'
|
|
|
import { reactive, ref } from 'vue'
|
|
|
-import { OrbitControls, useTweakPane, TransformControls } from '@tresjs/cientos/'
|
|
|
-import { useCamera } from '../core'
|
|
|
-import { TresCanvas } from '../core/useRenderer/component'
|
|
|
-/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
|
|
|
-
|
|
|
-const { updateCamera } = useCamera()
|
|
|
+import { OrbitControls, useTweakPane, TransformControls } from '@tresjs/cientos'
|
|
|
|
|
|
-updateCamera
|
|
|
+/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
|
|
|
|
|
|
-const state = reactive({
|
|
|
+const gl = reactive({
|
|
|
clearColor: '#201919',
|
|
|
shadows: true,
|
|
|
alpha: false,
|
|
|
- useLegacyLights: true,
|
|
|
shadowMapType: BasicShadowMap,
|
|
|
outputEncoding: sRGBEncoding,
|
|
|
toneMapping: NoToneMapping,
|
|
@@ -37,16 +32,13 @@ const sphereRef = ref()
|
|
|
|
|
|
const { pane } = useTweakPane()
|
|
|
|
|
|
-pane.addInput(state, 'clearColor', {
|
|
|
+pane.addInput(gl, 'clearColor', {
|
|
|
label: 'Background Color',
|
|
|
colorMode: 'hex',
|
|
|
})
|
|
|
-pane.addInput(state, 'shadows', {
|
|
|
+pane.addInput(gl, 'shadows', {
|
|
|
label: 'Shadows',
|
|
|
})
|
|
|
-pane.addInput(state, 'useLegacyLights', {
|
|
|
- label: 'useLegacyLights',
|
|
|
-})
|
|
|
|
|
|
pane
|
|
|
.addBlade({
|
|
@@ -59,7 +51,7 @@ pane
|
|
|
value: sRGBEncoding,
|
|
|
})
|
|
|
.on('change', ev => {
|
|
|
- state.outputEncoding = ev.value
|
|
|
+ gl.outputEncoding = ev.value
|
|
|
})
|
|
|
|
|
|
pane
|
|
@@ -75,7 +67,7 @@ pane
|
|
|
value: BasicShadowMap,
|
|
|
})
|
|
|
.on('change', ev => {
|
|
|
- state.shadowMapType = ev.value
|
|
|
+ gl.shadowMapType = ev.value
|
|
|
})
|
|
|
|
|
|
pane
|
|
@@ -94,50 +86,33 @@ pane
|
|
|
})
|
|
|
.on('change', ev => {
|
|
|
console.log(ev.value)
|
|
|
- state.toneMapping = ev.value
|
|
|
+ gl.toneMapping = ev.value
|
|
|
})
|
|
|
|
|
|
-function onPointerEnter(ev) {
|
|
|
- console.log('onPointerEnter', ev)
|
|
|
-}
|
|
|
-
|
|
|
-function onPointerMove(ev) {
|
|
|
- console.log('onPointerMove', ev)
|
|
|
-}
|
|
|
+const canvasRef = ref(null)
|
|
|
|
|
|
-function onPointerLeave(ev) {
|
|
|
- console.log('onPointerLeave', ev)
|
|
|
-}
|
|
|
-function onClick(ev) {
|
|
|
- console.log('click', ev)
|
|
|
-}
|
|
|
+watchEffect(() => {
|
|
|
+ if (canvasRef.value) {
|
|
|
+ console.log(canvasRef.value)
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
<template>
|
|
|
- <TresCanvas v-bind="state">
|
|
|
+ <TresCanvas v-bind="gl" ref="canvasRef">
|
|
|
<TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[-8, 3, -3]" />
|
|
|
<OrbitControls make-default />
|
|
|
- <TresScene>
|
|
|
- <TresAmbientLight :intensity="0.5" />
|
|
|
- <TransformControls mode="scale" :object="sphereRef" />
|
|
|
+ <TresAmbientLight :intensity="0.5" />
|
|
|
+ <TransformControls mode="scale" :object="sphereRef" />
|
|
|
|
|
|
- <TresMesh
|
|
|
- ref="sphereRef"
|
|
|
- :position="[0, 4, 0]"
|
|
|
- cast-shadow
|
|
|
- @pointer-enter="onPointerEnter"
|
|
|
- @pointer-move="onPointerMove"
|
|
|
- @pointer-leave="onPointerLeave"
|
|
|
- @click="onClick"
|
|
|
- >
|
|
|
- <TresSphereGeometry />
|
|
|
- <TresMeshToonMaterial color="#FBB03B" />
|
|
|
- </TresMesh>
|
|
|
- <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
|
|
|
- <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
|
|
|
- <TresPlaneGeometry :args="[10, 10, 10, 10]" />
|
|
|
- <TresMeshToonMaterial />
|
|
|
- </TresMesh>
|
|
|
- <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
|
|
|
- </TresScene>
|
|
|
+ <TresMesh ref="sphereRef" :position="[0, 4, 0]" cast-shadow>
|
|
|
+ <TresSphereGeometry />
|
|
|
+ <TresMeshToonMaterial color="#FBB03B" />
|
|
|
+ </TresMesh>
|
|
|
+ <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
|
|
|
+ <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
|
|
|
+ <TresPlaneGeometry :args="[10, 10, 10, 10]" />
|
|
|
+ <TresMeshToonMaterial />
|
|
|
+ </TresMesh>
|
|
|
+ <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
|
|
|
</TresCanvas>
|
|
|
</template>
|