3D-viewer v2 #1870

Merged
btzr-io merged 16 commits from three-v2 into master 2018-08-22 21:10:06 +02:00
btzr-io commented 2018-08-13 05:40:22 +02:00 (Migrated from github.com)

Todo [WIP]

## Todo [WIP] - [x] Add controls. [dat.gui](https://github.com/dataarts/dat.gui) - [x] Minor Threejs [optimizations](https://rawgit.com/moroine/three.js/b4afbcd39f5de332e2251f86924da29fc9f8831b/docs/#manual/introduction/Optimizations) - [x] Fix memory leak https://github.com/lbryio/lbry-desktop/issues/1863 - [x] Remove debug messages. - [x] Minor geometry (BufferGeometry) optimization https://github.com/lbryio/lbry-desktop/pull/1870#pullrequestreview-145911218. - [x] Fix `material.flatShading`. - [x] Bug-fix: Set `mesh.center` as camera target for all loaders.
skhameneh (Migrated from github.com) reviewed 2018-08-13 05:40:22 +02:00
kauffj commented 2018-08-13 16:01:54 +02:00 (Migrated from github.com)

@seanyesmunt if you can tell @jamesbiller how to run this version he can confirm the issue has been fixed

@seanyesmunt if you can tell @jamesbiller how to run this version he can confirm the issue has been fixed
tzarebczan commented 2018-08-13 16:50:45 +02:00 (Migrated from github.com)

@jamesbiller try this build here: http://build.lbry.io/app/build-3096_commit-612dd80/

I'll test it out today as well.

@jamesbiller try this build here: http://build.lbry.io/app/build-3096_commit-612dd80/ I'll test it out today as well.
skhameneh (Migrated from github.com) reviewed 2018-08-14 06:14:44 +02:00
@ -14,4 +17,3 @@
autoRotate: boolean,
source: {
fileType: string,
downloadPath: string,
skhameneh (Migrated from github.com) commented 2018-08-14 06:14:44 +02:00

Might want to add geometry.mergeVertices();

and if you end up having issues mapping textures, this might help:

function updateGeometryUv(geometry) {
  let max = geometry.boundingBox.max,
      min = geometry.boundingBox.min;
  let offset = new THREE.Vector2(0 - min.x, 0 - min.y);
  let range = new THREE.Vector2(max.x - min.x, max.y - min.y);
  let faces = geometry.faces;

  geometry.faceVertexUvs[0] = [];

  for(let i = 0; i < faces.length ; i++) {

      let v1 = geometry.vertices[faces[i].a],
          v2 = geometry.vertices[faces[i].b],
          v3 = geometry.vertices[faces[i].c];

      geometry.faceVertexUvs[0].push([
          new THREE.Vector2((v1.x + offset.x)/range.x ,(v1.y + offset.y)/range.y),
          new THREE.Vector2((v2.x + offset.x)/range.x ,(v2.y + offset.y)/range.y),
          new THREE.Vector2((v3.x + offset.x)/range.x ,(v3.y + offset.y)/range.y)
      ]);
  }
  geometry.uvsNeedUpdate = true;
}
Might want to add `geometry.mergeVertices();` and if you end up having issues mapping textures, this might help: ``` function updateGeometryUv(geometry) { let max = geometry.boundingBox.max, min = geometry.boundingBox.min; let offset = new THREE.Vector2(0 - min.x, 0 - min.y); let range = new THREE.Vector2(max.x - min.x, max.y - min.y); let faces = geometry.faces; geometry.faceVertexUvs[0] = []; for(let i = 0; i < faces.length ; i++) { let v1 = geometry.vertices[faces[i].a], v2 = geometry.vertices[faces[i].b], v3 = geometry.vertices[faces[i].c]; geometry.faceVertexUvs[0].push([ new THREE.Vector2((v1.x + offset.x)/range.x ,(v1.y + offset.y)/range.y), new THREE.Vector2((v2.x + offset.x)/range.x ,(v2.y + offset.y)/range.y), new THREE.Vector2((v3.x + offset.x)/range.x ,(v3.y + offset.y)/range.y) ]); } geometry.uvsNeedUpdate = true; } ```
skhameneh (Migrated from github.com) reviewed 2018-08-14 06:15:58 +02:00
@ -14,4 +17,3 @@
autoRotate: boolean,
source: {
fileType: string,
downloadPath: string,
skhameneh (Migrated from github.com) commented 2018-08-14 06:15:58 +02:00

Also, some of the operations might be faster if you can do them before you convert the GeometryBuffer into a Geometry

Also, some of the operations might be faster if you can do them before you convert the `GeometryBuffer` into a `Geometry`
skhameneh commented 2018-08-14 06:16:37 +02:00 (Migrated from github.com)

Looks good!

Looks good!
tzarebczan commented 2018-08-14 15:26:40 +02:00 (Migrated from github.com)

@btzr-io definitely noticing an improvement with memory usage after leaving the 3d model (takes a few seconds) - it does seem to release the memory allocated. If you open multiple after another, you can still get pretty high usage on some 3d models.

@jamesbiller how's this working on your PC?

@btzr-io definitely noticing an improvement with memory usage after leaving the 3d model (takes a few seconds) - it does seem to release the memory allocated. If you open multiple after another, you can still get pretty high usage on some 3d models. @jamesbiller how's this working on your PC?
jamesbiller commented 2018-08-14 17:56:39 +02:00 (Migrated from github.com)

@tzarebczan It's been working a hell of a lot smoother! Good work

@tzarebczan It's been working a hell of a lot smoother! Good work
btzr-io (Migrated from github.com) reviewed 2018-08-15 02:00:37 +02:00
@ -14,4 +17,3 @@
autoRotate: boolean,
source: {
fileType: string,
downloadPath: string,
btzr-io (Migrated from github.com) commented 2018-08-15 02:00:37 +02:00

We don't really support textures ATM so that won't be a problem...

We don't really support textures ATM so that won't be a problem...
btzr-io commented 2018-08-19 21:27:08 +02:00 (Migrated from github.com)

Ready for review and more testing.

Ready for review and more testing.
neb-b commented 2018-08-20 18:41:04 +02:00 (Migrated from github.com)

@btzr-io The new controls are awesome! It looks good from testing, I'll let @skhameneh do the dev review since he has a better understanding of the threejs stuff.

@btzr-io The new controls are awesome! It looks good from testing, I'll let @skhameneh do the dev review since he has a better understanding of the threejs stuff.
tzarebczan commented 2018-08-21 16:21:57 +02:00 (Migrated from github.com)

@btzr-io from initial testing, you could also check off Fix memory leak #1863 - it's definitely better in this version.

@btzr-io from initial testing, you could also check off `Fix memory leak #1863` - it's definitely better in this version.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#1870
No description provided.