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

Feature/sof 5474 1 #6

Merged
merged 10 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 28 additions & 5 deletions .github/workflows/ci.yml
@@ -1,17 +1,16 @@
name: CI

on:
pull_request:
paths-ignore:
- 'build/**'
- 'docs/**'
- 'files/**'
push:
paths-ignore:
- 'build/**'
- 'docs/**'
- 'files/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

lint:
Expand Down Expand Up @@ -96,3 +95,27 @@ jobs:

- name: === Ready for release ===
run: npm run test-e2e-cov

publish:
name: "Publish package"
needs: [lint, unit, e2e, e2e-cov]
runs-on: ubuntu-latest
if: github.ref_name == 'dev'

steps:
- name: Git checkout
uses: actions/checkout@v2

- name: Checkout actions repository
uses: actions/checkout@v2
with:
repository: Exabyte-io/actions
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: actions

- name: Publish release
uses: ./actions/js/publish
with:
npm-token: ${{ secrets.NPM_TOKEN }}
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
verify-tests: false
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -82,3 +82,10 @@ git clone --depth=1 https://github.com/mrdoob/three.js.git
[discord]: https://img.shields.io/discord/685241246557667386
[discord-url]: https://discord.gg/56GBJwAnUS

### Notes

This fork is introducing adjustments to the Editor to (1) make it reusable and (2) focus on 3D design of materials/chemicals.

Known Issues:

- Codemirror Dependency on Tern.JS https://github.com/Exabyte-io/three.js/pull/6/files#diff-164db2a22a4c894e29fdccb6def3bfcf77c385084b8a0f6bdbce66146d2f5a88R3
20 changes: 13 additions & 7 deletions editor/js/Editor.js
@@ -1,19 +1,24 @@
import * as THREE from 'three';
import { Signal } from "signals";

import { Config } from './Config.js';
import { Loader } from './Loader.js';
import { History as _History } from './History.js';
import { Strings } from './Strings.js';
import { Storage as _Storage } from './Storage.js';

import '../css/main.css';

var _DEFAULT_CAMERA = new THREE.PerspectiveCamera( 50, 1, 0.01, 1000 );
_DEFAULT_CAMERA.name = 'Camera';
_DEFAULT_CAMERA.position.set( 0, 5, 10 );
_DEFAULT_CAMERA.lookAt( new THREE.Vector3() );

function Editor() {
function Editor( providedDefaultCamera ) {

this.DEFAULT_CAMERA = providedDefaultCamera || _DEFAULT_CAMERA;

var Signal = signals.Signal;
var signal = new Signal();

this.signals = {

Expand Down Expand Up @@ -95,7 +100,7 @@ function Editor() {

this.loader = new Loader( this );

this.camera = _DEFAULT_CAMERA.clone();
this.camera = this.DEFAULT_CAMERA.clone();

this.scene = new THREE.Scene();
this.scene.name = 'Scene';
Expand Down Expand Up @@ -398,11 +403,12 @@ Editor.prototype = {

if ( helper === undefined ) {

if ( object.isCamera ) {
// if ( object.isCamera ) {

helper = new THREE.CameraHelper( object );
// helper = new THREE.CameraHelper( object );

} else if ( object.isPointLight ) {
// } else
if ( object.isPointLight ) {

helper = new THREE.PointLightHelper( object, 1 );

Expand Down Expand Up @@ -608,7 +614,7 @@ Editor.prototype = {
this.history.clear();
this.storage.clear();

this.camera.copy( _DEFAULT_CAMERA );
this.camera.copy( this.DEFAULT_CAMERA );
this.signals.cameraResetted.dispatch();

this.scene.name = 'Scene';
Expand Down
4 changes: 2 additions & 2 deletions editor/js/Menubar.Edit.js
Expand Up @@ -150,7 +150,7 @@ function MenubarEdit( editor ) {

//

options.add( new UIHorizontalRule() );
// options.add( new UIHorizontalRule() );

// Set textures to sRGB. See #15903

Expand All @@ -162,7 +162,7 @@ function MenubarEdit( editor ) {
editor.scene.traverse( fixColorMap );

} );
options.add( option );
// options.add( option );

const colorMaps = [ 'map', 'envMap', 'emissiveMap' ];

Expand Down
8 changes: 4 additions & 4 deletions editor/js/Menubar.File.js
Expand Up @@ -35,11 +35,11 @@ function MenubarFile( editor ) {
}

} );
options.add( option );
// options.add( option );

//

options.add( new UIHorizontalRule() );
// options.add( new UIHorizontalRule() );

// Import

Expand All @@ -66,11 +66,11 @@ function MenubarFile( editor ) {
fileInput.click();

} );
options.add( option );
// options.add( option );

//

options.add( new UIHorizontalRule() );
// options.add( new UIHorizontalRule() );

// Export Geometry

Expand Down
20 changes: 10 additions & 10 deletions editor/js/Menubar.js
@@ -1,12 +1,12 @@
import { UIPanel } from './libs/ui.js';

import { MenubarAdd } from './Menubar.Add.js';
// import { MenubarAdd } from './Menubar.Add.js';
import { MenubarEdit } from './Menubar.Edit.js';
import { MenubarFile } from './Menubar.File.js';
import { MenubarExamples } from './Menubar.Examples.js';
import { MenubarView } from './Menubar.View.js';
import { MenubarHelp } from './Menubar.Help.js';
import { MenubarPlay } from './Menubar.Play.js';
//import { MenubarExamples } from './Menubar.Examples.js';
//import { MenubarView } from './Menubar.View.js';
//import { MenubarHelp } from './Menubar.Help.js';
//import { MenubarPlay } from './Menubar.Play.js';
import { MenubarStatus } from './Menubar.Status.js';

function Menubar( editor ) {
Expand All @@ -16,11 +16,11 @@ function Menubar( editor ) {

container.add( new MenubarFile( editor ) );
container.add( new MenubarEdit( editor ) );
container.add( new MenubarAdd( editor ) );
container.add( new MenubarPlay( editor ) );
container.add( new MenubarExamples( editor ) );
container.add( new MenubarView( editor ) );
container.add( new MenubarHelp( editor ) );
// container.add( new MenubarAdd( editor ) );
// container.add( new MenubarPlay( editor ) );
// container.add( new MenubarExamples( editor ) );
// container.add( new MenubarView( editor ) );
// container.add( new MenubarHelp( editor ) );

container.add( new MenubarStatus( editor ) );

Expand Down
5 changes: 5 additions & 0 deletions editor/js/Script.js
@@ -1,4 +1,9 @@
import { UIElement, UIPanel, UIText } from './libs/ui.js';
import CodeMirror from "codemirror";
// TODO : resolve global tern reference in CodeMirror.TernServer
import tern from "ternjs";
import "codemirror/addon/tern/tern";
import "codemirror/addon/tern/tern.css";

import { SetScriptValueCommand } from './commands/SetScriptValueCommand.js';
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
Expand Down
6 changes: 3 additions & 3 deletions editor/js/Sidebar.Animation.js
Expand Up @@ -23,13 +23,13 @@ function SidebarAnimation( editor ) {
const name = new UIText( animation.name ).setWidth( '200px' );
container.add( name );

const button = new UIButton( getButtonText( action ) );
const button = new UIButton( getButtonText( action ) );
button.onClick( function () {

console.log( action );
// console.log( action );

action.isRunning() ? action.stop() : action.play();
button.setTextContent( getButtonText( action ) );
button.setTextContent( getButtonText( action ) );

} );

Expand Down
2 changes: 1 addition & 1 deletion editor/js/Sidebar.Geometry.BufferGeometry.js
Expand Up @@ -15,7 +15,7 @@ function SidebarGeometryBufferGeometry( editor ) {

const geometry = object.geometry;

if ( geometry && geometry.isBufferGeometry ) {
if ( geometry && geometry.isBufferGeometry && object.type !== 'LineSegments' ) {

container.clear();
container.setDisplay( 'block' );
Expand Down
88 changes: 88 additions & 0 deletions editor/js/Sidebar.Geometry.LineSegments.js
@@ -0,0 +1,88 @@
import { UIRow, UINumber, UIText, UIButton } from './libs/ui.js';
/**
* LineSegments Geometry function to visualize and update cell configuration.
*/
function GeometryParametersPanel( editor, object ) {

var signals = editor.signals;
var container = new UIRow();

// set lattice a,b, and c vectors based on the LineSegments vertices
const vertices = object.geometry.vertices;
const a = vertices[ 1 ].sub( vertices[ 0 ] ).toArray();
const b = vertices[ 3 ].sub( vertices[ 0 ] ).toArray();
const c = vertices[ 17 ].sub( vertices[ 0 ] ).toArray();

// lattice a vector
var aRow = new UIRow();
var aX = new UINumber( a[ 0 ] ).setWidth( '50px' );
var aY = new UINumber( a[ 1 ] ).setWidth( '50px' );
var aZ = new UINumber( a[ 2 ] ).setWidth( '50px' );
aRow.add( new UIText( 'Lattice "a"' ).setWidth( '90px' ) );
aRow.add( aX, aY, aZ );
container.add( aRow );

// lattice b vector
var bRow = new UIRow();
var bX = new UINumber( b[ 0 ] ).setWidth( '50px' );
var bY = new UINumber( b[ 1 ] ).setWidth( '50px' );
var bZ = new UINumber( b[ 2 ] ).setWidth( '50px' );
bRow.add( new UIText( 'Lattice "b"' ).setWidth( '90px' ) );
bRow.add( bX, bY, bZ );
container.add( bRow );

// lattice c vector
var cRow = new UIRow();
var cX = new UINumber( c[ 0 ] ).setWidth( '50px' );
var cY = new UINumber( c[ 1 ] ).setWidth( '50px' );
var cZ = new UINumber( c[ 2 ] ).setWidth( '50px' );
cRow.add( new UIText( 'Lattice "c"' ).setWidth( '90px' ) );
cRow.add( cX, cY, cZ );
container.add( cRow );

const applyButton = new UIButton( 'Apply Edits' ).onClick( () => update( object ) );
container.add( applyButton );

function update( object ) {

container.setDisplay( 'block' );
const cell = {
ax: aX.getValue(),
ay: aY.getValue(),
az: aZ.getValue(),
bx: bX.getValue(),
by: bY.getValue(),
bz: bZ.getValue(),
cx: cX.getValue(),
cy: cY.getValue(),
cz: cZ.getValue(),
};
const vertices = [
[ 0, 0, 0 ],
[ cell.ax, cell.ay, cell.az ],
[ cell.bx, cell.by, cell.bz ],
[ ( cell.ax + cell.bx ), ( cell.ay + cell.by ), ( cell.az + cell.bz ) ],
[ cell.cx, cell.cy, cell.cz ],
[ ( cell.cx + cell.ax ), ( cell.cy + cell.ay ), ( cell.cz + cell.az ) ],
[ ( cell.cx + cell.bx ), ( cell.cy + cell.by ), ( cell.cz + cell.bz ) ],
[ ( cell.cx + cell.ax + cell.bx ), ( cell.cy + cell.ay + cell.by ), ( cell.cz + cell.az + cell.bz ) ]
];

// edges of the cell forming a continuous line
const edges = [ 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7 ];

const newGeometry = new THREE.Geometry();

edges.forEach( edge => newGeometry.vertices.push( new THREE.Vector3( vertices[ edge ][ 0 ], vertices[ edge ][ 1 ], vertices[ edge ][ 2 ] ) ) );

editor.execute( new SetGeometryCommand( object, newGeometry ) );

}

return container;

}

Sidebar.Geometry.LineSegments = GeometryParametersPanel;

export { GeometryParametersPanel };
2 changes: 1 addition & 1 deletion editor/js/Sidebar.Geometry.js
Expand Up @@ -191,7 +191,7 @@ function SidebarGeometry( editor ) {

parameters.clear();

if ( geometry.type === 'BufferGeometry' ) {
if ( geometry.type === 'BufferGeometry' || geometry.type === 'Geometry' ) {

parameters.add( new SidebarGeometryModifiers( editor, object ) );

Expand Down