LDraw.org Discussion Forums

Full Version: 3D Part Preview added to Parts Tracker
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11
(2019-07-16, 2:00)Orion Pobursky Wrote: [ -> ]I'm sure it's possible but Lasse will need to chime in about how to do it.

A quick and dirty approach to this is to use the same type of method overwriting as for the other modes:

Code:
var acceptedColors = [1, 2, 4, 5, 13, 14, 19, 22, 25, 27, 69, 71, 72, 73, 74, 77, 288, 308, 484];
   THREE.LDRStep.prototype.addSubModel = function(subModel) {
     subModel.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)];
     this.subModels.push(subModel);
   }

This leaves each type of part with a random color. All studs on a brick will thus be colored the same random color.

If you want each part to have its own color (such as each stud on a brick in its own color) then additional functions have to be overwritten.
(2019-07-16, 6:41)Lasse Deleuran Wrote: [ -> ]A quick and dirty approach to this is to use the same type of method overwriting as for the other modes:

Code:
  var acceptedColors = [1, 2, 4, 5, 13, 14, 19, 22, 25, 27, 69, 71, 72, 73, 74, 77, 288, 308, 484];
   THREE.LDRStep.prototype.addSubModel = function(subModel) {
     subModel.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)];
     this.subModels.push(subModel);
   }

This leaves each type of part with a random color. All studs on a brick will thus be colored the same random color.

If you want each part to have its own color (such as each stud on a brick in its own color) then additional functions have to be overwritten.

I think what is wanted is the colors for all the quads/tri/and subparts in the top level file to be randomized.
(2019-07-16, 13:50)Orion Pobursky Wrote: [ -> ]I think what is wanted is the colors for all the quads/tri/and subparts in the top level file to be randomized.

The following should cover that scenario:

Code:
// Half-Harlequin-mode:
      var acceptedColors = [1, 2, 4, 5, 13, 14, 19, 22, 25, 27, 69, 71, 72, 73, 74, 77, 288, 308, 484];
      THREE.LDRStep.prototype.addSubModel = function(subModel) {
        subModel.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)];
        this.subModels.push(subModel);
      }
      LDR.LDRGeometry.prototype.fromPartType = function(loader, pt) {
        loader.getMainModel().IS_MAIN_MODEL = true;
        let geometries = [];
        if(pt.steps.length === 0) {
          console.warn("No steps in " + pt.ID);
          return; // Empty - just make empty.
        }
        if(pt.IS_MAIN_MODEL) { // Harlequin the triangles and quads:
          pt.steps.forEach(step => {
            step.quads.forEach(quad => quad.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);
            step.triangles.forEach(triangle => triangle.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);
          });
        }

        pt.steps.forEach(step => {
            let g = new LDR.LDRGeometry();
            g.fromStep(loader, step);
            geometries.push(g);
        });

        this.replaceWith(LDR.mergeGeometries(geometries));
      }

It took me a bit longer to come up with this solution that I would like to admit! Big Grin
This is now implemented. Loading speed has greatly improved.
(2019-07-18, 6:42)Lasse Deleuran Wrote: [ -> ]The following should cover that scenario:

Code:
      // Half-Harlequin-mode:
      var acceptedColors = [1, 2, 4, 5, 13, 14, 19, 22, 25, 27, 69, 71, 72, 73, 74, 77, 288, 308, 484];
      THREE.LDRStep.prototype.addSubModel = function(subModel) {
        subModel.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)];
        this.subModels.push(subModel);
      }
      LDR.LDRGeometry.prototype.fromPartType = function(loader, pt) {
        loader.getMainModel().IS_MAIN_MODEL = true;
        let geometries = [];
        if(pt.steps.length === 0) {
          console.warn("No steps in " + pt.ID);
          return; // Empty - just make empty.
        }
        if(pt.IS_MAIN_MODEL) { // Harlequin the triangles and quads:
          pt.steps.forEach(step => {
            step.quads.forEach(quad => quad.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);
            step.triangles.forEach(triangle => triangle.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);
          });
        }

        pt.steps.forEach(step => {
            let g = new LDR.LDRGeometry();
            g.fromStep(loader, step);
            geometries.push(g);
        });

        this.replaceWith(LDR.mergeGeometries(geometries));
      }

It took me a bit longer to come up with this solution that I would like to admit! Big Grin

I've implemented this but the rendering has errors:

[attachment=3849]
Looks like BFC coloring is fooled by noclip statements. See:
https://www.ldraw.org/cgi-bin/ptdetail.c...231p01.dat
https://www.ldraw.org/cgi-bin/ptdetail.c...69bpz4.dat
https://www.ldraw.org/cgi-bin/ptdetail.c...086ps1.dat
These files show 3 different types of wrong rendering.

Also: I have had problems with zooming level (goes to extreme zoom in) when rapidly switching between rendering modes and rotate view. So far I've not been able to reproduce this reliably.
(2019-07-18, 22:38)Orion Pobursky Wrote: [ -> ]I've implemented this but the rendering has errors:
That's no good! Can you please share the file you are viewing?

I am unable to replicate the issue with the files I have on hand for testing.

EDIT: I found a part that fails. I will be able to look at this once I get home tonight.
(2019-07-19, 7:00)Lasse Deleuran Wrote: [ -> ]That's no good! Can you please share the file you are viewing?

I am unable to replicate the issue with the files I have on hand for testing.

EDIT: I found a part that fails. I will be able to look at this once I get home tonight.

The one pictured above is this one:

https://www.ldraw.org/cgi-bin/ptdetail.c...675ps1.dat
(2019-07-19, 6:44)Philippe Hurbain Wrote: [ -> ]Looks like BFC coloring is fooled by noclip statements. See:
https://www.ldraw.org/cgi-bin/ptdetail.c...231p01.dat
https://www.ldraw.org/cgi-bin/ptdetail.c...69bpz4.dat
https://www.ldraw.org/cgi-bin/ptdetail.c...086ps1.dat
These files show 3 different types of wrong rendering.

I already noticed this and PM'd Lasse

(2019-07-19, 6:44)Philippe Hurbain Wrote: [ -> ]Also: I have had problems with zooming level (goes to extreme zoom in) when rapidly switching between rendering modes and rotate view. So far I've not been able to reproduce this reliably.

This is probably caused by 2 bits of code trying to run at the same time since part loading is asynchonous.
(2019-07-19, 12:20)Orion Pobursky Wrote: [ -> ]The one pictured above is this one:

https://www.ldraw.org/cgi-bin/ptdetail.c...675ps1.dat

This, in combination with the 'half harlequin' mode turned out to be a great stress test of the geometry-optimization for the renderer. I have pushed a fix of 'js/LDRGeometries' to master.

Content of the bug fix: This diff on GitHub
Pages: 1 2 3 4 5 6 7 8 9 10 11