Skip to content

Commit

Permalink
NodeEditor: cleanup (#23332)
Browse files Browse the repository at this point in the history
* add AngleEditor

* cleanup
  • Loading branch information
sunag authored Jan 25, 2022
1 parent 1a0abe4 commit 1a1d338
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 12 deletions.
16 changes: 14 additions & 2 deletions examples/jsm/node-editor/NodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InvertEditor } from './math/InvertEditor.js';
import { LimiterEditor } from './math/LimiterEditor.js';
import { DotEditor } from './math/DotEditor.js';
import { PowerEditor } from './math/PowerEditor.js';
import { AngleEditor } from './math/AngleEditor.js';
import { TrigonometryEditor } from './math/TrigonometryEditor.js';
import { FloatEditor } from './inputs/FloatEditor.js';
import { Vector2Editor } from './inputs/Vector2Editor.js';
Expand Down Expand Up @@ -130,9 +131,15 @@ export const NodeList = [
{
name: 'Trigonometry',
icon: 'wave-sine',
tip: 'Sin / Cos / Tan',
tip: 'Sin / Cos / Tan / ...',
nodeClass: TrigonometryEditor
},
{
name: 'Angle',
icon: 'angle',
tip: 'Degress / Radians',
nodeClass: AngleEditor
},
{
name: 'Normalize',
icon: 'fold',
Expand Down Expand Up @@ -210,6 +217,7 @@ export const ClassLib = {
LimiterEditor,
DotEditor,
PowerEditor,
AngleEditor,
TrigonometryEditor,
FloatEditor,
Vector2Editor,
Expand Down Expand Up @@ -346,7 +354,11 @@ export class NodeEditor extends EventDispatcher {

newButton.onClick( () => {

if ( confirm( 'are you sure' ) ) this.newProject();
if ( confirm( 'Are you sure?' ) === true ) {

this.newProject();

}

} );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/node-editor/accessors/NormalEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NormalEditor extends BaseNode {
{ name: 'Local', value: NormalNode.LOCAL },
{ name: 'World', value: NormalNode.WORLD },
{ name: 'View', value: NormalNode.VIEW },
{ name: 'Geometry', value: NormalNode.GEOMETRY },
{ name: 'Geometry', value: NormalNode.GEOMETRY }
], NormalNode.LOCAL ).onChange( () => {

node.scope = optionsField.getValue();
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/node-editor/accessors/PositionEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class PositionEditor extends BaseNode {
{ name: 'Local', value: PositionNode.LOCAL },
{ name: 'World', value: PositionNode.WORLD },
{ name: 'View', value: PositionNode.VIEW },
{ name: 'ViewDirection', value: PositionNode.VIEW_DIRECTION },
{ name: 'View Direction', value: PositionNode.VIEW_DIRECTION }
], PositionNode.LOCAL ).onChange( () => {

node.scope = optionsField.getValue();
Expand Down
39 changes: 39 additions & 0 deletions examples/jsm/node-editor/math/AngleEditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
import { BaseNode } from '../core/BaseNode.js';
import { MathNode, Vector3Node } from '../../renderers/nodes/Nodes.js';

const DEFAULT_VALUE = new Vector3Node();

export class AngleEditor extends BaseNode {

constructor() {

const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );

super( 'Angle', 1, node, 175 );

const optionsField = new SelectInput( [
{ name: 'Degrees to Radians', value: MathNode.RAD },
{ name: 'Radians to Degrees', value: MathNode.DEG }
], MathNode.RAD ).onChange( () => {

node.method = optionsField.getValue();

this.invalidate();

} );

const input = new LabelElement( 'A' ).setInput( 1 );

input.onConnect( () => {

node.aNode = input.getLinkedObject() || DEFAULT_VALUE;

} );

this.add( new Element().add( optionsField ) )
.add( input );

}

}
7 changes: 2 additions & 5 deletions examples/jsm/node-editor/math/TrigonometryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ export class TrigonometryEditor extends BaseNode {

const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );

super( 'Angle / Trigonometry', 1, node, 220 );
super( 'Trigonometry', 1, node, 175 );

const optionsField = new SelectInput( [
{ name: 'Radian', value: MathNode.RAD },
{ name: 'Degree', value: MathNode.DEG },

{ name: 'Sin', value: MathNode.SIN },
{ name: 'Cos', value: MathNode.COS },
{ name: 'Tan', value: MathNode.TAN },

{ name: 'asin', value: MathNode.ASIN },
{ name: 'acos', value: MathNode.ACOS },
{ name: 'atan', value: MathNode.ATAN },
{ name: 'atan', value: MathNode.ATAN }
], MathNode.SIN ).onChange( () => {

node.method = optionsField.getValue();
Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/nodes/math/MathNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MathNode extends TempNode {

return this.b ? 2 : 1;

// 3
// 3

case MathNode.MIX:
case MathNode.CLAMP:
Expand All @@ -34,7 +34,7 @@ class MathNode extends TempNode {

return 3;

// 2
// 2

case MathNode.MIN:
case MathNode.MAX:
Expand All @@ -48,7 +48,7 @@ class MathNode extends TempNode {

return 2;

// 1
// 1

default:

Expand Down

0 comments on commit 1a1d338

Please sign in to comment.