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

NodeEditor: Fixes #23309

Merged
merged 2 commits into from
Jan 25, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions examples/jsm/node-editor/NodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const NodeList = [
{
name: 'Normalize',
icon: 'fold',
nodeClass: OperatorEditor
nodeClass: NormalizeEditor
}
]
},
Expand Down Expand Up @@ -504,41 +504,45 @@ export class NodeEditor extends EventDispatcher {

const object3d = this.scene;

object3d.traverse( ( obj3d ) => {
if ( object3d !== null ) {

object3d.traverse( ( obj3d ) => {

if ( obj3d.isMesh === true ) {

if ( obj3d.isMesh === true ) {
const button = new ButtonInput( `Mesh - ${obj3d.name}` );
button.setIcon( 'ti ti-3d-cube-sphere' );
button.addEventListener( 'complete', () => {

const button = new ButtonInput( `Mesh - ${obj3d.name}` );
button.setIcon( `ti ti-3d-cube-sphere` );
button.addEventListener( 'complete', () => {
for ( const node of this.canvas.nodes ) {

for ( const node of this.canvas.nodes ) {
if ( node.value === obj3d ) {

if ( node.value === obj3d ) {
// not duplicated node

// not duplicated node
this.canvas.select( node );

this.canvas.select( node );
return;

return;
}

}

}
const node = new MeshEditor( obj3d );

const node = new MeshEditor( obj3d );
this.add( node );

this.add( node );
this.centralizeNode( node );

this.centralizeNode( node );
} );

} );
search.add( button );

search.add( button );
}

}
} );

} );
}

} );

Expand Down
22 changes: 11 additions & 11 deletions examples/jsm/node-editor/scene/MeshEditor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NumberInput, StringInput, LabelElement } from '../../libs/flow.module.js';
import { BaseNode } from '../core/BaseNode.js';
import { Mesh, MathUtils, Vector3} from '../../../../build/three.module.js';
import { Mesh, MathUtils, Vector3 } from 'three';

export class MeshEditor extends BaseNode {

Expand Down Expand Up @@ -35,9 +35,9 @@ export class MeshEditor extends BaseNode {
setEditor( editor ) {

if ( this.editor ) {

this._restoreDefault();

}

super.setEditor( editor );
Expand Down Expand Up @@ -148,7 +148,7 @@ export class MeshEditor extends BaseNode {
const mesh = this.mesh;

if ( mesh ) {

const { position, rotation, scale } = mesh;

position.x = this.posX.getValue();
Expand All @@ -158,17 +158,17 @@ export class MeshEditor extends BaseNode {
rotation.x = MathUtils.degToRad( this.rotX.getValue() );
rotation.y = MathUtils.degToRad( this.rotY.getValue() );
rotation.z = MathUtils.degToRad( this.rotZ.getValue() );

scale.x = this.scaleX.getValue() / 100;
scale.y = this.scaleY.getValue() / 100;
scale.z = this.scaleZ.getValue() / 100;

mesh.material = this.material || this.defaultMaterial;

}

}

updateDefault() {

const { material, position, rotation, scale } = this.mesh;
Expand All @@ -182,9 +182,9 @@ export class MeshEditor extends BaseNode {
this._restoreDefault();

}

_restoreDefault() {

const position = this.defaultPosition;
const rotation = this.defaultRotation;
const scale = this.defaultScale;
Expand All @@ -200,9 +200,9 @@ export class MeshEditor extends BaseNode {
this.scaleX.setValue( scale.x );
this.scaleY.setValue( scale.y );
this.scaleZ.setValue( scale.z );

this.mesh.material = this.defaultMaterial;

}

}
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