From ec61c9ed22c82de41eb32518aaff8f49f2b844c9 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 4 Jan 2022 08:15:26 -0500 Subject: [PATCH] more debugging. fix version in kiri workers --- src/kiri/worker.js | 2 ++ src/main/mesh.js | 2 +- src/mesh/model.js | 38 +++++++++++++++++--------------------- src/mesh/tool.js | 1 + src/mesh/work.js | 2 +- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/kiri/worker.js b/src/kiri/worker.js index 6fad99b2..50a88f8b 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -21,6 +21,8 @@ let BASE = self.base, minifns = {}, miniseq = 0; +KIRI.version = gapp.version; + // catch clipper alerts and convert to console messages self.alert = function(o) { console.log(o); diff --git a/src/main/mesh.js b/src/main/mesh.js index 0a149ffd..b23a3a83 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -198,7 +198,7 @@ function space_init(data) { .then(data => { if (data) { console.log({data}); - m.load( + m.reload( // Float32Array.from(data.vertices.toFloat32()), Float32Array.from([...data.v]), Uint32Array.from([...data.f]) diff --git a/src/mesh/model.js b/src/mesh/model.js index 64d1fffc..9cd8c0e7 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -90,14 +90,11 @@ mesh.model = class MeshModel extends mesh.object { } load(vertices, indices) { - this.wireframe(false); let geo = new THREE.BufferGeometry(); geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); if (indices) geo.setIndex(new THREE.BufferAttribute(indices, 1)); geo.computeVertexNormals(); - // reuse mesh if this is a "reload" - let meh = this.mesh || new THREE.Mesh(geo, materials.unselected); - meh.geometry = geo; + let meh = new THREE.Mesh(geo, materials.unselected); meh.receiveShadow = true; meh.castShadow = true; meh.renderOrder = 1; @@ -105,28 +102,27 @@ mesh.model = class MeshModel extends mesh.object { meh.model = this; // sync data to worker worker.model_load({id: this.id, name: this.file, vertices, indices}); - // update mesh in group - // if (this.group) this.group.update(oldmesh, meh); return meh; } - optimize() { - let ind = THREE.BufferGeometryUtils.mergeVertices(this.mesh.geometry); - console.log({geo: this.mesh.geometry, ind}); + optimize(geo) { + let ind = THREE.BufferGeometryUtils.mergeVertices(geo || this.mesh.geometry); + console.log({geo: geo || this.mesh.geometry.clone(), ind}); + return ind; } - // reload(vertices, indices) { - // this.wireframe(false); - // let geo = this.mesh.geometry; - // geo.attributes.position.array = vertices; - // geo.attributes.position.needsUpdate = true; - // geo.setAttribute('normal', undefined); - // if (indices) { - // geo.setIndex(new THREE.BufferAttribute(indices, 1)); - // } - // geo.computeVertexNormals(); - // worker.model_load({id: this.id, name: this.name, vertices, indices}); - // } + reload(vertices, indices) { + this.wireframe(false); + let geo = this.mesh.geometry; + geo.attributes.position.array = vertices; + geo.attributes.position.needsUpdate = true; + geo.setAttribute('normal', undefined); + if (indices) { + geo.setIndex(new THREE.BufferAttribute(indices, 1)); + } + geo.computeVertexNormals(); + worker.model_load({id: this.id, name: this.name, vertices, indices}); + } get group() { return this._group; diff --git a/src/mesh/tool.js b/src/mesh/tool.js index 0e705ce8..38849b3c 100644 --- a/src/mesh/tool.js +++ b/src/mesh/tool.js @@ -87,6 +87,7 @@ mesh.tool = class MeshTool { } vertices = nuvt; this.stats = {cull, dups, faces:faces.length/3}; + // console.log({stats: this.stats}); } else { faces = faces.map(v => v*3); } diff --git a/src/mesh/work.js b/src/mesh/work.js index 4373cd15..4919d8ea 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -55,7 +55,7 @@ let model = { debug: false }); dbug.log('...imported data'); - tool.heal(); + // tool.heal(); dbug.log('...healed'); dbug.log(tool); return true || tool.newFaces ? {