From 26ab54bd6603f7cb533f9cc124f9fe48659bd883 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Tue, 15 Sep 2020 14:59:34 +0200 Subject: [PATCH] wip --- public/test.glb | Bin 0 -> 4848 bytes src/App.vue | 5 ++-- src/components/Test2.vue | 9 +++++--- src/components/TestGLTF.vue | 14 +++++++++++ src/components/viewers/GLTFViewer.vue | 32 ++++++++++++++++++++++++++ src/core/Scene.js | 5 +++- src/lights/Light.js | 6 +++-- 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 public/test.glb create mode 100644 src/components/TestGLTF.vue create mode 100644 src/components/viewers/GLTFViewer.vue diff --git a/public/test.glb b/public/test.glb new file mode 100644 index 0000000000000000000000000000000000000000..d632e5fea520c3b7b4c3e65f70e6d702ee7bf9d5 GIT binary patch literal 4848 zcmc&#Npl-j5dIP%ED1QoEQS!G3=l|AoSD(AMgn4!#aV2}4qwewy<|>y? z?F8`KKA^b^I6E;qvSJkDIBFOJE5=+@jq1flt!@k$=jQ9RYAw#pQAlR65>;oSdS>|e zXlB{!rz>Yb|?7szK!sApNDTAPXZftj_Y zR;OD3SB!-yo>##-Vz5$+44-B?Q1=WO?=iWm+7B$Ostn}`y$MKGYo?;@N!g9!UgQ~k;>tdr(FHbKu`0t7_ zHaanUX?S#m8g?~nl&dr45oyG03+LARVSuJ8E<;4;$7}x6S;-;5o zXQTS%a&%oyP^q@CSgS_W#-$sJGy$$dO9tJYr39G z)d+0cb;F#eim}1hmimSem3n7P_X2K}xk|Eg4@Ks@pE^FtoOHEnC%Zy*#Pp3ubUv!i zHRu&1+{T(>uHkZwHRUExw+P zPDSXaE%ImxGMP-@9$;{I1b1&AEzq%sTVdwM`i{Ty-`|@o?EUH}*`F!@y4~_i{N3B% z<$w6Kx4^MCOFuOO@5tKew|hBujX8B}lQ`EjXX=;uo28+(Z+piMbFAiEV@}E6v2K&r zO)zXL4TMqrI+t`^$*FTxdOG|PpYoH=JmpnjZQ52jlIB99`N)-?Jl`6_bx`;%{LKVU zzp1TjlEkvV$());*-}G?Kdry!Q931t`S=z(lU&mJQ+?7p$h9P=^h>;~t+eId$-Zj$ zs~+31FR};pTDm`5Jt_SXPj=cHT91mAdnfg@`&;}vU$rl?SLM20dOlezt*x%1;_1?> z3g4lb_d@$+Z@0}?KEX)-cFk%w)w;3{?fP5$F12Yrde)?d7QQ|A)_X&1P(7yCUE}va zyI_&*1=`$3bLp2nJrDC;RatUczC#j8||3N6CALz7OG5WN{4rI1UpQY~>sDgtg{}M&uk9wsN^w~wUzIAty%fWX3dG6@<=?{`Q(hyc$K@vNS-c! ziC1T$=2W)iB)e0863ZHrSU$57TWXWBX)cmeuiF%7sN&%oGw$EamyVV5sAf>Ft7^;p z#{YRXrJgSS1g~)0oiEa$@SSr?Yc=`aWbRaLNkh7p#!J7NYu3!TE^{a6Xw&&(eR@t) zJFpn~>;u_s$RIq?5YFNa_s3S%LOIXHr{0+f?7oY$D literal 0 HcmV?d00001 diff --git a/src/App.vue b/src/App.vue index 343b97d..dfebf2a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,15 +11,16 @@ import Test1 from './components/Test1.vue'; import Test2 from './components/Test2.vue'; import Test3 from './components/Test3.vue'; +import TestGLTF from './components/TestGLTF.vue'; export default { name: 'App', components: { - Test1, Test2, Test3, + Test1, Test2, Test3, TestGLTF, }, data() { return { - tests: ['Test1', 'Test2', 'Test3'], + tests: ['Test1', 'Test2', 'Test3', 'TestGLTF'], test: 'Test1', }; }, diff --git a/src/components/Test2.vue b/src/components/Test2.vue index a83eded..6c74dcc 100644 --- a/src/components/Test2.vue +++ b/src/components/Test2.vue @@ -5,7 +5,7 @@ - + @@ -31,8 +31,6 @@ export default { InstancedMesh, BoxGeometry, }, mounted() { - const renderer = this.$refs.renderer; - const { randFloat: rnd, randFloatSpread: rndFS } = MathUtils; const imesh = this.$refs.imesh.mesh; const dummy = new Object3D(); @@ -46,7 +44,12 @@ export default { } imesh.instanceMatrix.needsUpdate = true; + const renderer = this.$refs.renderer; + const light = this.$refs.light.light; renderer.onBeforeRender(() => { + const t = Date.now() * 0.0001; + const c1 = Math.cos(t), c2 = c1 * Math.sin(t * 1.4), c3 = c2 * Math.cos(t * 0.3); + light.position.set(c1 * 100, c2 * 100, c3 * 100); }); }, }; diff --git a/src/components/TestGLTF.vue b/src/components/TestGLTF.vue new file mode 100644 index 0000000..1efaa75 --- /dev/null +++ b/src/components/TestGLTF.vue @@ -0,0 +1,14 @@ + + + diff --git a/src/components/viewers/GLTFViewer.vue b/src/components/viewers/GLTFViewer.vue new file mode 100644 index 0000000..1129fc9 --- /dev/null +++ b/src/components/viewers/GLTFViewer.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/core/Scene.js b/src/core/Scene.js index b4613d5..caf7783 100644 --- a/src/core/Scene.js +++ b/src/core/Scene.js @@ -18,6 +18,9 @@ export default { this.three.scene = this.scene; }, render() { - return this.$slots.default(); + if (this.$slots.default) { + return this.$slots.default(); + } + return []; }, }; diff --git a/src/lights/Light.js b/src/lights/Light.js index 8d525df..dfdb13e 100644 --- a/src/lights/Light.js +++ b/src/lights/Light.js @@ -21,8 +21,10 @@ export default { mounted() { setFromProp(this.light.position, this.position); - this.light.castShadow = this.castShadow; - setFromProp(this.light.shadow.mapSize, this.shadowMapSize); + if (this.light.shadow) { + this.light.castShadow = this.castShadow; + setFromProp(this.light.shadow.mapSize, this.shadowMapSize); + } this.scene.add(this.light); if (this.light.target) this.scene.add(this.light.target);