Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCodeLoader and example #12897

Merged
merged 12 commits into from
Dec 18, 2017
Merged

GCodeLoader and example #12897

merged 12 commits into from
Dec 18, 2017

Conversation

tentone
Copy link
Contributor

@tentone tentone commented Dec 17, 2017

Hi

Added a GCodeLoader and a example page using the benchy model http://www.3dbenchy.com/.

This loader was based on the loader made by @joewalnes.

Thanks a lot!

Cumps

@tentone tentone changed the title GCoder and example GCodeLoader and example Dec 17, 2017
@takahirox
Copy link
Collaborator

I think you should follow the Code Style https://github.com/mrdoob/three.js/wiki/Mr.doob's-Code-Style%E2%84%A2

@WestLangley
Copy link
Collaborator

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

Updated code to follow the format used in repository!

@takahirox Thanks a lot!

var self = this;

var loader = new THREE.FileLoader( self.manager );
loader.setPath( this.path );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be deleted, see #12731

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 18, 2017

I still have 83 ESLint errors with the current loader. Please use https://zz85.github.io/mrdoobapproves/ or a linter plugin to resolve these problems.


function animate() {

controls.update();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the controls is not necessary...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also change the scope of controls. This variable does not need to be global...

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

@Mugen87

Reformated the code and removed controls update from the example.

Cumps


this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being so pedantic 😇 . Missing semicolon here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem i think you should be 👍,


if ( currentLayer === undefined ) {
newLayer( line );
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like so...

if ( currentLayer === undefined ) {

   newLayer( line );

}

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

Updated the code, removed trailing spaces and fixed spacing in if/for

@WestLangley
Copy link
Collaborator

The example renders with 242 draw calls.

Also, why is the model rendered with lines? I assume it is intentional...

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

Yes it is intentional, GCode stores paths used by CNC / 3D printer machines, can be usefull to preview data for these kind of systems.

For convenience i have splitted it by layers, thats why it renders with so many draw calls.

@WestLangley
Copy link
Collaborator

For convenience i have splitted it by layers, thats why it renders with so many draw calls.

I assume the layers are only required by the CNC... Can you fairly easily create only one instance of THREE.LineSegments per material? ... Or is it not worth it?

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

I can but i think its not worth it.

But i can add an option to have the path all in one Object.

type: grouptype,
feed: line.e,
extruding: line.extruding,
geometry: new THREE.Geometry(),
Copy link
Collaborator

@Mugen87 Mugen87 Dec 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: It would be actually better to produce BufferGeometry since we try to remove Geometry from the loaders.

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

Moved to buffer geometry, but im also adding this to a single LineSegments object ;)

@tentone
Copy link
Contributor Author

tentone commented Dec 18, 2017

Moved to a single geometry, with option to split by layer!

function addObject(vertex, extruding) {

var geometry = new THREE.BufferGeometry();
geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertex ), 3 ) );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of

new THREE.BufferAttribute( new Float32Array( vertex ), 3 )

write it like this

new THREE.Float32BufferAttribute( vertex, 3 )

Copy link
Collaborator

@Mugen87 Mugen87 Dec 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please check the code style again. There are some new formatting issues.

https://zz85.github.io/mrdoobapproves/

@WestLangley
Copy link
Collaborator

There is no need for an animation loop with a static scene. Please use this pattern, instead:

controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render );
controls.minDistance = 5; // whatever
controls.maxDistance = 100; // whatever

... and add a call to render() in the loader callback.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 18, 2017

@WestLangley Good point!

@mrdoob
Copy link
Owner

mrdoob commented Dec 18, 2017

Merging for now.

@mrdoob mrdoob merged commit 187fbc2 into mrdoob:dev Dec 18, 2017
@mrdoob
Copy link
Owner

mrdoob commented Dec 18, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants