diff --git a/public/test.glb b/public/test.glb
new file mode 100644
index 0000000..d632e5f
Binary files /dev/null and b/public/test.glb differ
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);