phetsims / build-a-molecule

"Build a Molecule" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
8 stars 7 forks source link

3D view with mobius #104

Closed jonathanolson closed 4 years ago

jonathanolson commented 4 years ago

The common code should be ready, using ThreeNode (you give it a width/height, and it acts basically like a rectangle in the view, as long as you call layout() on it whenever its position on-screen may have changed). It's potentially in flux, but it would be good to collaborate to get this working.

I hacked up a quick test in another screen view, with:

      this.tmp = new ThreeNode( 300, 150 );
      this.tmpPanel = new Panel( this.tmp );
      this.tmpPanel.center = this.layoutBounds.center;
      this.addChild( this.tmpPanel );

      this.tmp.stage.threeScene.add( new THREE.Mesh( new THREE.SphereGeometry( 4, 30, 24 ), new THREE.MeshLambertMaterial( {
        color: 0xffaa44
      } ) ) );

      const tmpAmbientLight = new THREE.AmbientLight( 0x555555 );
      this.tmp.stage.threeScene.add( tmpAmbientLight );

      const tmpSunLight = new THREE.DirectionalLight( 0xffffff, 1 );
      tmpSunLight.position.set( -1, 1.5, 0.8 );
      this.tmp.stage.threeScene.add( tmpSunLight );

and the following running every frame:

      this.tmpPanel.center = this.layoutBounds.center;
      this.tmp.layout();
      this.tmp.render( undefined );

resulting in the stays-in-center view:

Screen Shot 2019-10-22 at 1 12 09 PM

@Denz1994, let me know when it would be good to collaborate on this.

Denz1994 commented 4 years ago

ThreeJS implementation has been completed with the help of @jonathanolson. Molecule3DDialog.js houses all of the main components for visual modeling and BAMScreenView.js is responsible for rendering. Additional features include an automated rotation with the ability to pause and stop the rotation, along with the ability to drag the 3D model around in the dialog

The 3D modeling is stable in its current state and any further bugs should be reported in a different issue. Closing this one.