@threepipe/plugin-blend-importer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ /* eslint-disable camelcase, no-unused-vars, no-empty, no-constant-condition */
2
+ import {createThreeJSBufferGeometry} from './mesh.js';
3
+ import {createThreeJSMaterial} from './material.js';
4
+ import {Mesh} from 'threepipe';
5
+ import {createThreeJSLamp} from './light.js';
6
+
7
+ const blender_object_types = {
8
+ mesh: 1,
9
+ lamp: 10,
10
+ };
11
+
12
+ function createObject (blender_file, object) {
13
+
14
+ if (object.data) {
15
+ // get the mesh
16
+ const buffered_geometry = createThreeJSBufferGeometry(object.data, [0, 0, 0]);
17
+
18
+ console.log(object)
19
+ const blend_material = object.data.mat[0];
20
+
21
+ const material = blend_material ? createThreeJSMaterial(blend_material) : null;
22
+
23
+ const mesh = new Mesh(buffered_geometry, material);
24
+
25
+ mesh.castShadow = true;
26
+ mesh.receiveShadow = true;
27
+
28
+ mesh.rotateZ(object.rot[2]);
29
+ mesh.rotateY(object.rot[1]);
30
+ mesh.rotateX(object.rot[0]);
31
+ mesh.scale.fromArray(object.size, 0);
32
+ mesh.position.fromArray([object.loc[0], (object.loc[2]), (-object.loc[1])], 0);
33
+
34
+ return mesh;
35
+ }
36
+
37
+ return null;
38
+ }
39
+
40
+ function loadObject (object_name, blender_file, cache) {
41
+ const objects = blender_file.Object;
42
+
43
+ for (let i = 0; i < objects.length; i++) {
44
+ let object = objects[i];
45
+
46
+ if (object.aname === object_name) {
47
+ switch (object.type) {
48
+ case blender_object_types.mesh:
49
+ return createObject(object, blender_file);
50
+ case blender_object_types.lamp:
51
+ return createThreeJSLamp(object, blender_file);
52
+ default:
53
+ console.warn('Unsupported object type', object.type);
54
+ }
55
+ }
56
+ }
57
+
58
+ return null;
59
+ }
60
+
61
+ function loadScene (three_scene, blender_file, cache) {
62
+
63
+ for (let i = 0; i < blender_file.objects.Object.length; i++) {
64
+
65
+ let object = blender_file.objects.Object[i];
66
+
67
+ // Load Lights
68
+ if (object.type === blender_object_types.lamp) {
69
+ let light = createThreeJSLamp(object, blender_file);
70
+ three_scene.add(light);
71
+ }
72
+
73
+ // Load Meshes
74
+ if (object.type === blender_object_types.mesh) {
75
+ let mesh = createObject(blender_file, object);
76
+ if(mesh) {
77
+ three_scene.add(mesh);
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ export default function (blender_file) {
84
+
85
+ const cache = {};
86
+
87
+ return {
88
+ loadScene: (three_scene) => loadScene(three_scene, blender_file, cache),
89
+ loadObject: (object_name) => loadObject(object_name, blender_file, cache),
90
+ };
91
+ }
@@ -0,0 +1,47 @@
1
+ /* eslint-disable camelcase, no-unused-vars, no-empty, no-constant-condition */
2
+ import {PointLight} from 'threepipe';
3
+
4
+ const blender_light_types = {
5
+ point: 0,
6
+ sun: 1,
7
+ spot: 0,
8
+ hemi: 0,
9
+ area: 0,
10
+ };
11
+
12
+ export function createThreeJSLamp (blend_lamp) {
13
+
14
+ console.log(blend_lamp)
15
+
16
+ let ldata = blend_lamp.data;
17
+
18
+ let pos_array = [blend_lamp.loc[0], blend_lamp.loc[2], -blend_lamp.loc[1]];
19
+
20
+ let color = ((ldata.r * 255) << 16) | ((ldata.g * 255) << 8) | ((ldata.b * 255) << 0);
21
+ // let intesity = 20;
22
+ let intesity = ldata.energy;
23
+ let distance = 0;
24
+
25
+ let three_light = null;
26
+
27
+ switch (ldata.type) {
28
+ case blender_light_types.point:
29
+ three_light = new PointLight(color, intesity, distance);
30
+ three_light.position.fromArray(pos_array, 0);
31
+ three_light.castShadow = true;
32
+ break;
33
+ case blender_light_types.sun:
34
+ three_light = new PointLight(color, intesity, distance);
35
+ three_light.position.fromArray(pos_array, 0);
36
+ three_light.castShadow = true;
37
+ three_light.shadow.mapSize.width = 1024;
38
+ three_light.shadow.mapSize.height = 1024;
39
+ three_light.shadow.camera.near = 0.01;
40
+ three_light.shadow.camera.far = 500;
41
+ break;
42
+ default:
43
+ console.warn('Unsupported light type', ldata.type);
44
+ }
45
+
46
+ return three_light;
47
+ }
@@ -0,0 +1,175 @@
1
+ /* eslint-disable camelcase, no-unused-vars, no-empty, no-constant-condition */
2
+ import {createThreeJSTexture} from './texture.js';
3
+ import {CubeReflectionMapping, EquirectangularReflectionMapping, MeshPhysicalMaterial} from 'threepipe';
4
+
5
+ const texture_mappings = {
6
+ diff_color: 1,
7
+ normal: 2,
8
+ mirror: 8,
9
+ diff_intensity: 16,
10
+ spec_intensity: 32,
11
+ emit: 32,
12
+ alpha: 128,
13
+ spec_hardness: 256,
14
+ ray_mirror: 512,
15
+ translucency: 1024,
16
+ ambient: 2048,
17
+ displacement: 4096,
18
+ warp: 8192,
19
+ };
20
+
21
+ let blender_specular_types = {
22
+ cooktorr: 0,
23
+ phong: 1,
24
+ blinn: 2,
25
+ toon: 3,
26
+ wardiso: 4,
27
+ };
28
+
29
+ function applyColorMapping (blender_texture, three_texture, material) {
30
+ if (blender_texture.mapto & texture_mappings.diff_color) {
31
+ material.map = three_texture;
32
+ }
33
+ }
34
+
35
+ function applySpecMapping (blender_texture, three_texture, material) {
36
+ if (blender_texture.mapto & texture_mappings.spec_color && material.type != 'MeshStandardMaterial') {
37
+ material.specularMap = three_texture;
38
+ }
39
+
40
+ if (blender_texture.mapto & texture_mappings.spec_intensity && material.type != 'MeshStandardMaterial') {
41
+ material.roughnessMap = three_texture;
42
+ }
43
+ }
44
+
45
+ function applyAlphaMapping (blender_texture, three_texture, material) {
46
+ if (blender_texture.mapto & texture_mappings.alpha) {
47
+ material.alphaMap = three_texture;
48
+ }
49
+ }
50
+
51
+ function applyNormalMapping (blender_texture, three_texture, material) {
52
+ if (blender_texture.mapto & texture_mappings.normal) {
53
+ material.normalMap = three_texture;
54
+ material.normalScale = {
55
+ x: blender_texture.norfac,
56
+ y: blender_texture.norfac,
57
+ };
58
+ }
59
+ }
60
+
61
+ function applyMirrorMapping (blender_texture, three_texture, material) {
62
+ if (blender_texture.mapto & texture_mappings.mirror) {
63
+ material.envMap = three_texture;
64
+ material.envMapIntensity = blender_texture.mirrfac;
65
+ }
66
+ }
67
+
68
+ const blender_texture_coordinates = {
69
+ GENERATED: 1,
70
+ REFLECTION: 2,
71
+ NORMAL: 4,
72
+ GLOBAL: 8,
73
+ UV: 16,
74
+ OBJECT: 32,
75
+ WINDOW: 1024,
76
+ TANGENT: 4096,
77
+ PARTICLE: 8192,
78
+ STRESS: 16384,
79
+ };
80
+
81
+ const blender_texture_mapping = {
82
+ FLAT: 0,
83
+ CUBE: 1,
84
+ TUBE: 2,
85
+ SPHERE: 3,
86
+ };
87
+
88
+ function applyTexture (blender_texture, material) {
89
+ // extract blender_texture data. Use Only if image has been supplied.
90
+ if (blender_texture && blender_texture.tex && blender_texture.tex.ima) {
91
+
92
+ let three_texture = createThreeJSTexture(blender_texture.tex.ima);
93
+
94
+ if(blender_texture.texco == blender_texture_coordinates.REFLECTION) {
95
+ switch(blender_texture.mapping) {
96
+ case blender_texture_mapping.FLAT:
97
+ three_texture.mapping = EquirectangularReflectionMapping;
98
+ break;
99
+ case blender_texture_mapping.SPHERE:
100
+ three_texture.mapping = CubeReflectionMapping;
101
+ break;
102
+ default: break;
103
+ }
104
+ // three_texture.mapping = EquirectangularRefractionMapping;
105
+ }
106
+
107
+ applyColorMapping(blender_texture, three_texture, material);
108
+
109
+ applySpecMapping(blender_texture, three_texture, material);
110
+
111
+ applyAlphaMapping(blender_texture, three_texture, material);
112
+
113
+ applyNormalMapping(blender_texture, three_texture, material);
114
+
115
+ applyMirrorMapping(blender_texture, three_texture, material);
116
+ }
117
+ }
118
+
119
+ export function createThreeJSMaterial (blend_mat) {
120
+
121
+ console.log(blend_mat)
122
+
123
+ let material = new MeshPhysicalMaterial();
124
+ material.color.setRGB(blend_mat.r, blend_mat.g, blend_mat.b);
125
+ material.roughness = blend_mat.roughness !== undefined ? blend_mat.roughness : 0.4
126
+ material.metalness = blend_mat.metallic !== undefined ? blend_mat.metallic : 0.0
127
+ material.opacity = blend_mat.alpha !== undefined ? blend_mat.alpha : 0.0
128
+ material.tranparent = material.opacity < 1.0
129
+
130
+ // todo textures and nodes
131
+ // const textures = blend_mat.mtex;
132
+
133
+ // switch (blend_mat.spec_shader) {
134
+ // case blender_specular_types.lambert:
135
+ // material = new MeshLambertMaterial();
136
+ // material.color.setRGB(blend_mat.r, blend_mat.g, blend_mat.b);
137
+ // break;
138
+ // case blender_specular_types.blinn:
139
+ // case blender_specular_types.phong:
140
+ //
141
+ // material = new MeshStandardMaterial();
142
+ // material.color.setRGB(blend_mat.r, blend_mat.g, blend_mat.b);
143
+ // // material.specular.setRGB(blend_mat.specr, blend_mat.specg, blend_mat.specb);
144
+ // material.roughness = (1 - (blend_mat.har / 512));
145
+ // material.metalness = 1 - blend_mat.ref;
146
+ // if(blend_mat.alpha < 0.98) {
147
+ // material.transparent = true;
148
+ // material.opacity = blend_mat.alpha;
149
+ // console.log(blend_mat, material)
150
+ // }
151
+ // break;
152
+ // case blender_specular_types.wardiso:
153
+ // case blender_specular_types.cooktorr:
154
+ // material = new MeshPhongMaterial();
155
+ // material.color.setRGB(blend_mat.r, blend_mat.g, blend_mat.b);
156
+ // material.specular.setRGB(blend_mat.specr, blend_mat.specg, blend_mat.specb);
157
+ // material.shininess = blend_mat.har / 512;
158
+ // material.reflectivity = blend_mat.ref * 100;
159
+ // break;
160
+ // default:
161
+ // material = new MeshStandardMaterial();
162
+ // // material = new MeshLambertMaterial();
163
+ // material.color.setRGB(blend_mat.r, blend_mat.g, blend_mat.b);
164
+ // material.roughness = 0.5;
165
+ // material.metalness = 0;
166
+ // break;
167
+ // }
168
+
169
+ // const at = (texture) => applyTexture(texture, material);
170
+ //
171
+ // if (textures && textures.length) textures.map(at);
172
+
173
+ return material;
174
+ }
175
+
@@ -0,0 +1,209 @@
1
+ /* eslint-disable camelcase, no-unused-vars, no-empty, no-constant-condition */
2
+
3
+ import {BufferAttribute, BufferGeometry} from 'threepipe';
4
+
5
+ export function createBufferGeometry (blender_mesh, origin) {
6
+ // get materials
7
+ let pick_material = 0,
8
+ mesh = blender_mesh,
9
+ faces = mesh.mpoly,
10
+ loops = mesh.mloop,
11
+ UV = mesh.mloopuv,
12
+ verts = mesh.mvert;
13
+
14
+ const geometry = new BufferGeometry();
15
+
16
+ if (!faces) return geometry;
17
+
18
+ let index_count = 0;
19
+
20
+ // precalculate the size of the array needed for faces
21
+ let face_indice_count = 0;
22
+ let face_indice_counta = 0;
23
+
24
+ for (let i = 0; i < faces.length; i++) {
25
+ const face = faces[i] || faces;
26
+ const len = face.totloop;
27
+ let indexi = 1;
28
+
29
+ face_indice_counta += (len * 2 / 3) | 0;
30
+
31
+ while (indexi < len) {
32
+ face_indice_count += 3;
33
+ indexi += 2;
34
+ }
35
+ }
36
+
37
+ // extract face info and dump into array buffer;
38
+ const face_buffer = new Uint32Array(face_indice_count);
39
+ const uv_buffer = new Float32Array(face_indice_count * 2);
40
+ const normal_buffer = new Float32Array(face_indice_count * 3);
41
+ const verts_array_buff = new Float32Array(face_indice_count * 3);
42
+
43
+ for (let i = 0; i < faces.length; i++) {
44
+ const face = faces[i] || faces;
45
+ const len = face.totloop;
46
+ const start = face.loopstart;
47
+ let indexi = 1;
48
+ const offset = 0;
49
+
50
+ while (indexi < len) {
51
+ const face_normals = [];
52
+ const face_index_array = [];
53
+ const face_uvs = [];
54
+
55
+ let index = 0;
56
+
57
+ for (let l = 0; l < 3; l++) {
58
+ // Per Vertice
59
+
60
+ if ((indexi - 1) + l < len) {
61
+ index = start + (indexi - 1) + l;
62
+ } else {
63
+ index = start;
64
+ }
65
+
66
+ const v = loops[index].v;
67
+ const vert = verts[v];
68
+ face_buffer[index_count] = index_count;
69
+ // get normals, which are 16byte ints, and norm them back into floats.
70
+
71
+ verts_array_buff[index_count * 3 + 0] = vert.co[0] + origin[0];
72
+ verts_array_buff[index_count * 3 + 1] = vert.co[2] + origin[2];
73
+ verts_array_buff[index_count * 3 + 2] = -vert.co[1] + -origin[1];
74
+
75
+ normal_buffer[index_count * 3 + 0] = vert.no[0];
76
+ normal_buffer[index_count * 3 + 1] = vert.no[2];
77
+ normal_buffer[index_count * 3 + 2] = (-vert.no[1]);
78
+
79
+
80
+ if (UV) {
81
+ const uv = UV[index].uv;
82
+ uv_buffer[index_count * 2 + 0] = uv[0];
83
+ uv_buffer[index_count * 2 + 1] = uv[1];
84
+ }
85
+
86
+ index_count++;
87
+ }
88
+
89
+ indexi += 2;
90
+ }
91
+ }
92
+
93
+ geometry.setAttribute('position', new BufferAttribute(verts_array_buff, 3));
94
+ geometry.setIndex(new BufferAttribute(face_buffer, 1));
95
+ geometry.setAttribute('normal', new BufferAttribute(normal_buffer, 3));
96
+ geometry.setAttribute('uv', new BufferAttribute(uv_buffer, 2));
97
+ // geometry.blend_mat = materials[pick_material];
98
+
99
+ return geometry;
100
+ }
101
+
102
+ // function createThreeJSGeometry (blender_mesh, origin) {
103
+ // // get materials
104
+ // const mats = blender_mesh.mat,
105
+ // materials = [];
106
+ // for (var i = 0; i < mats.length; i++) {
107
+ // const material = createThreeJSMaterial(mats[i]);
108
+ // materials.push(material);
109
+ // }
110
+ //
111
+ // let pick_material = 0,
112
+ // mesh = blender_mesh,
113
+ // faces = mesh.mpoly,
114
+ // loops = mesh.mloop,
115
+ // UV = mesh.mloopuv,
116
+ // verts = mesh.mvert,
117
+ // vert_array = [],
118
+ // face_array = [],
119
+ // uv_array = [],
120
+ // normal_array = [];
121
+ //
122
+ // const geometry = new Geometry();
123
+ //
124
+ // if (!faces) return geometry;
125
+ //
126
+ //
127
+ // let index_count = 0;
128
+ //
129
+ // let verts_array_buff = new Float32Array(verts.length * 3);
130
+ //
131
+ // for (var i = 0; i < verts.length; i++) {
132
+ // let vert = verts[i];
133
+ // vert_array.push(new Vector3(vert.co[0] + origin[0], vert.co[2] + origin[2], -vert.co[1] - origin[1]));
134
+ // }
135
+ //
136
+ // for (var i = 0; i < faces.length; i++) {
137
+ // const face = faces[i] || faces;
138
+ // const len = face.totloop;
139
+ // const start = face.loopstart;
140
+ // let indexi = 1;
141
+ //
142
+ // pick_material = face.mat_nr;
143
+ //
144
+ // while (indexi < len) {
145
+ // const face_normals = [];
146
+ // const face_index_array = [];
147
+ // const face_uvs = [];
148
+ //
149
+ // let index = 0;
150
+ //
151
+ // for (let l = 0; l < 3; l++) {
152
+ // // Per Vertice
153
+ //
154
+ // if ((indexi - 1) + l < len) {
155
+ // index = start + (indexi - 1) + l;
156
+ // } else {
157
+ // index = start;
158
+ // }
159
+ //
160
+ // const v = loops[index].v;
161
+ // var vert = verts[v];
162
+ //
163
+ // face_index_array.push(v);
164
+ //
165
+ // index_count++;
166
+ //
167
+ // // get normals, which are 16byte ints, and norm them back into floats.
168
+ //
169
+ // const n1 = vert.no[0],
170
+ // n2 = vert.no[2],
171
+ // n3 = -vert.no[1];
172
+ //
173
+ // const nl = 1;
174
+ //
175
+ // Math.sqrt((n1 * n1) + (n2 * n2) + (n3 * n3));
176
+ //
177
+ // face_normals.push(new Vector3(n1 / nl, n2 / nl, n3 / nl));
178
+ //
179
+ // if (UV) {
180
+ // const uv = UV[index].uv;
181
+ // face_uvs.push(new Vector2(uv[0], uv[1]));
182
+ // }
183
+ // }
184
+ // uv_array.push(face_uvs);
185
+ // face_array.push(new Face3(
186
+ // face_index_array[0], face_index_array[1], face_index_array[2],
187
+ // face_normals,
188
+ // ));
189
+ //
190
+ // indexi += 2;
191
+ // }
192
+ // }
193
+ // geometry.blend_mat = materials[pick_material];
194
+ // geometry.vertices = vert_array;
195
+ // geometry.faces = face_array;
196
+ // if (uv_array.length > 0) {
197
+ // geometry.faceVertexUvs = [uv_array];
198
+ // }
199
+ //
200
+ // geometry.uvsNeedUpdate = true;
201
+ //
202
+ // // Well, using blender file normals does not work. Will need to investigate why normals from the blender file do not provide correct results.
203
+ // // For now, have Three calculate normals.
204
+ //
205
+ // geometry.computeVertexNormals();
206
+ //
207
+ //
208
+ // return geometry;
209
+ // }
@@ -0,0 +1,60 @@
1
+ /* eslint-disable camelcase, no-unused-vars, no-empty, no-constant-condition */
2
+ import {arrayBufferToBase64} from 'ts-browser-helpers';
3
+ import {Texture} from 'threepipe';
4
+
5
+ let blender_texture_cache = {};
6
+
7
+ export function createThreeJSTexture (image) {
8
+ let parsed_blend_file = image.__blender_file__;
9
+ let texture = null;
10
+ let name = image.aname;
11
+
12
+ if (image.packedfile) {
13
+
14
+ if (blender_texture_cache[name]) {
15
+ texture = blender_texture_cache[name];
16
+ } else {
17
+
18
+ // get the extension
19
+ let ext = name.split('.').pop();
20
+
21
+ let data = image.packedfile;
22
+
23
+ let size = data.size;
24
+
25
+ let offset = data.data.__data_address__;
26
+
27
+ let raw_data = parsed_blend_file.byte.slice(offset, offset + size);
28
+
29
+ let encodedData = arrayBufferToBase64(raw_data);
30
+
31
+ let dataURI;
32
+
33
+ switch (ext) {
34
+ case 'png':
35
+ dataURI = 'data:image/png;base64,' + encodedData;
36
+ break;
37
+ case 'jpg':
38
+ dataURI = 'data:image/jpeg;base64,' + encodedData;
39
+ break;
40
+ default:
41
+ console.warn('Unsupported image type', ext);
42
+ }
43
+
44
+ // eslint-disable-next-line no-undef
45
+ let img = new Image();
46
+
47
+ img.src = dataURI;
48
+
49
+ texture = new Texture(img);
50
+
51
+ img.onload = () => {
52
+ texture.needsUpdate = true;
53
+ // todo colorspace?
54
+ };
55
+
56
+ blender_texture_cache[name] = texture;
57
+ }
58
+ }
59
+ return texture;
60
+ }
@@ -0,0 +1,68 @@
1
+ import {BufferAttribute, BufferGeometry, Vector3Tuple} from 'threepipe'
2
+
3
+ export function createBufferGeometry(mesh: any, origin: Vector3Tuple) {
4
+ const
5
+ faces = Array.isArray(mesh.mpoly) ? mesh.mpoly as any[] : [mesh.mpoly],
6
+ loops = mesh.mloop,
7
+ uv = mesh.mloopuv,
8
+ vertices = mesh.mvert
9
+
10
+ const geometry = new BufferGeometry()
11
+
12
+ if (!faces) return geometry
13
+
14
+ const size = faces.reduce((acc, face) => acc + Math.floor(face.totloop * 3.0 / 2), 0)
15
+ const indices = new Uint32Array(size)
16
+ const uvs = new Float32Array(size * 2)
17
+ const normals = new Float32Array(size * 3)
18
+ const positions = new Float32Array(size * 3)
19
+
20
+ let currentIndex = 0
21
+
22
+ for (const face of faces) {
23
+ const len = face.totloop
24
+ const start = face.loopstart
25
+ let indexi = 1
26
+
27
+ while (indexi < len) {
28
+
29
+ let index = 0
30
+
31
+ for (let l = 0; l < 3; l++) {
32
+ // Per Vertex
33
+
34
+ index = start
35
+ if (indexi - 1 + l < len)
36
+ index += indexi - 1 + l
37
+
38
+ const loop = loops[index]
39
+ const vert = vertices[loop.v]
40
+ indices[currentIndex] = currentIndex
41
+
42
+ positions[currentIndex * 3 + 0] = vert.co[0] + origin[0]
43
+ positions[currentIndex * 3 + 1] = vert.co[2] + origin[2]
44
+ positions[currentIndex * 3 + 2] = -vert.co[1] + -origin[1]
45
+
46
+ normals[currentIndex * 3 + 0] = vert.no[0]
47
+ normals[currentIndex * 3 + 1] = vert.no[2]
48
+ normals[currentIndex * 3 + 2] = -vert.no[1]
49
+
50
+ if (uv) {
51
+ uvs[currentIndex * 2 + 0] = uv[index].uv[0]
52
+ uvs[currentIndex * 2 + 1] = uv[index].uv[1]
53
+ }
54
+
55
+ currentIndex++
56
+ }
57
+
58
+ indexi += 2
59
+ }
60
+ }
61
+
62
+ geometry.setAttribute('position', new BufferAttribute(positions, 3))
63
+ geometry.setIndex(new BufferAttribute(indices, 1))
64
+ geometry.setAttribute('normal', new BufferAttribute(normals, 3))
65
+ geometry.setAttribute('uv', new BufferAttribute(uvs, 2))
66
+
67
+ return geometry
68
+ }
@@ -0,0 +1,26 @@
1
+ import {createLight} from './light'
2
+ import {createMesh} from './mesh'
3
+ import {Object3D} from 'three'
4
+
5
+ const blenderObjectTypes = {
6
+ mesh: 1,
7
+ lamp: 10,
8
+ }
9
+
10
+ export async function createObjects(file: any) {
11
+ const objects: (Object3D|null)[] = []
12
+ const blendObjects = file.objects.Object
13
+ for (const object of blendObjects) {
14
+ switch (object.type) {
15
+ case blenderObjectTypes.mesh:
16
+ objects.push(createMesh(object))
17
+ break
18
+ case blenderObjectTypes.lamp:
19
+ objects.push(createLight(object))
20
+ break
21
+ default:
22
+ console.warn('Unsupported object type', object.type)
23
+ }
24
+ }
25
+ return objects.filter(o => !!o) as Object3D[]
26
+ }