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

[WIP] JSM: Move nodes/* #16054

Closed
wants to merge 4 commits into from
Closed
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
728 changes: 728 additions & 0 deletions examples/jsm/geometries/TeapotBufferGeometry.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
* @author sunag / http://www.sunag.com.br/
*/

THREE.NodeMaterialLoader = function ( manager, library ) {
import {
DefaultLoadingManager,
FileLoader
} from "../../../build/three.module.js";

this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
var NodeMaterialLoader = function ( manager, library ) {

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

this.nodes = {};
this.materials = {};
Expand All @@ -14,7 +19,7 @@ THREE.NodeMaterialLoader = function ( manager, library ) {

};

THREE.NodeMaterialLoaderUtils = {
var NodeMaterialLoaderUtils = {

replaceUUIDObject: function ( object, uuid, value, recursive ) {

Expand Down Expand Up @@ -66,13 +71,13 @@ THREE.NodeMaterialLoaderUtils = {

};

Object.assign( THREE.NodeMaterialLoader.prototype, {
Object.assign( NodeMaterialLoader.prototype, {

load: function ( url, onLoad, onProgress, onError ) {

var scope = this;

var loader = new THREE.FileLoader( scope.manager );
var loader = new FileLoader( scope.manager );
loader.setPath( scope.path );
loader.load( url, function ( text ) {

Expand Down Expand Up @@ -263,3 +268,5 @@ Object.assign( THREE.NodeMaterialLoader.prototype, {
}

} );

export { NodeMaterialLoader, NodeMaterialLoaderUtils };
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Math as _Math
} from "../../../../build/three.module.js";

function Node( type ) {

this.uuid = THREE.Math.generateUUID();
this.uuid = _Math.generateUUID();

this.name = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
CubeReflectionMapping,
CubeRefractionMapping,
CubeUVReflectionMapping,
CubeUVRefractionMapping,
GammaEncoding,
LinearEncoding
} from "../../../../build/three.module.js";

import { NodeUniform } from './NodeUniform.js';
import { NodeUtils } from './NodeUtils.js';
import { NodeLib } from './NodeLib.js';
Expand Down Expand Up @@ -771,15 +780,15 @@ NodeBuilder.prototype = {

switch ( nodeCandidate.mapping ) {

case THREE.CubeReflectionMapping:
case THREE.CubeRefractionMapping:
case CubeReflectionMapping:
case CubeRefractionMapping:

return new CubeTextureNode( nodeCandidate );

break;

case THREE.CubeUVReflectionMapping:
case THREE.CubeUVRefractionMapping:
case CubeUVReflectionMapping:
case CubeUVRefractionMapping:

return new TextureCubeNode( new TextureNode( nodeCandidate ) );

Expand Down Expand Up @@ -939,7 +948,7 @@ NodeBuilder.prototype = {

if ( ! map ) {

encoding = THREE.LinearEncoding;
encoding = LinearEncoding;

} else if ( map.isTexture ) {

Expand All @@ -953,9 +962,9 @@ NodeBuilder.prototype = {
}

// add backwards compatibility for WebGLRenderer.gammaInput/gammaOutput parameter, should probably be removed at some point.
if ( encoding === THREE.LinearEncoding && gammaOverrideLinear ) {
if ( encoding === LinearEncoding && gammaOverrideLinear ) {

encoding = THREE.GammaEncoding;
encoding = GammaEncoding;

}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Math as _Math
} from "../../../../build/three.module.js";

import { Node } from './Node.js';

function TempNode( type, params ) {
Expand All @@ -29,7 +33,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {

if ( isUnique && this.constructor.uuid === undefined ) {

this.constructor.uuid = THREE.Math.generateUUID();
this.constructor.uuid = _Math.generateUUID();

}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Vector2
} from "../../../../build/three.module.js";

import { TempNode } from '../core/TempNode.js';
import { FunctionNode } from '../core/FunctionNode.js';
import { FloatNode } from '../inputs/FloatNode.js';
Expand Down Expand Up @@ -135,7 +139,7 @@ BlurNode.prototype.copy = function ( source ) {
this.uv = source.uv;
this.radius = source.radius;

if ( source.size !== undefined ) this.size = new THREE.Vector2( source.size.x, source.size.y );
if ( source.size !== undefined ) this.size = new Vector2( source.size.x, source.size.y );

this.blurX = source.blurX;
this.blurY = source.blurY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Color
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';
import { NodeUtils } from '../core/NodeUtils.js';

function ColorNode( color, g, b ) {

InputNode.call( this, 'c' );

this.value = color instanceof THREE.Color ? color : new THREE.Color( color || 0, g, b );
this.value = color instanceof Color ? color : new Color( color || 0, g, b );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Matrix3
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';

function Matrix3Node( matrix ) {

InputNode.call( this, 'm3' );

this.value = matrix || new THREE.Matrix3();
this.value = matrix || new Matrix3();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Matrix4
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';

function Matrix4Node( matrix ) {

InputNode.call( this, 'm4' );

this.value = matrix || new THREE.Matrix4();
this.value = matrix || new Matrix4();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Mesh,
OrthographicCamera,
PlaneBufferGeometry,
Scene,
WebGLRenderTarget
} from "../../../../build/three.module.js";

import { NodeBuilder } from '../core/NodeBuilder.js';
import { NodeMaterial } from '../materials/NodeMaterial.js';
import { TextureNode } from './TextureNode.js';

Expand All @@ -13,14 +22,14 @@ function RTTNode( width, height, input, options ) {

this.clear = options.clear !== undefined ? options.clear : true;

this.renderTarget = new THREE.WebGLRenderTarget( width, height, options );
this.renderTarget = new WebGLRenderTarget( width, height, options );

this.material = new NodeMaterial();

this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new Scene();

this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material );
this.quad = new Mesh( new PlaneBufferGeometry( 2, 2 ), this.material );
this.quad.frustumCulled = false; // Avoid getting clipped
this.scene.add( this.quad );

Expand All @@ -36,7 +45,7 @@ RTTNode.prototype.nodeType = "RTT";

RTTNode.prototype.build = function ( builder, output, uuid ) {

var rttBuilder = new THREE.NodeBuilder();
var rttBuilder = new NodeBuilder();
rttBuilder.nodes = builder.nodes;
rttBuilder.updaters = builder.updaters;

Expand All @@ -59,9 +68,9 @@ RTTNode.prototype.updateFramesaveTo = function ( frame ) {
material.fragment.value = this;
material.build();

var scene = new THREE.Scene();
var scene = new Scene();

var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), material );
var quad = new Mesh( new PlaneBufferGeometry( 2, 2 ), material );
quad.frustumCulled = false; // Avoid getting clipped
scene.add( quad );

Expand Down Expand Up @@ -134,7 +143,7 @@ RTTNode.prototype.toJSON = function ( meta ) {

if ( ! data ) {

data = THREE.TextureNode.prototype.toJSON.call( this, meta );
data = TextureNode.prototype.toJSON.call( this, meta );

if ( this.saveTo ) data.saveTo = this.saveTo.toJSON( meta ).uuid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Vector2
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';
import { NodeUtils } from '../core/NodeUtils.js';

function Vector2Node( x, y ) {

InputNode.call( this, 'v2' );

this.value = x instanceof THREE.Vector2 ? x : new THREE.Vector2( x, y );
this.value = x instanceof Vector2 ? x : new Vector2( x, y );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Vector3
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';
import { NodeUtils } from '../core/NodeUtils.js';

function Vector3Node( x, y, z ) {

InputNode.call( this, 'v3' );

this.value = x instanceof THREE.Vector3 ? x : new THREE.Vector3( x, y, z );
this.value = x instanceof Vector3 ? x : new Vector3( x, y, z );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
* @author sunag / http://www.sunag.com.br/
*/

import {
Vector4
} from "../../../../build/three.module.js";

import { InputNode } from '../core/InputNode.js';
import { NodeUtils } from '../core/NodeUtils.js';

function Vector4Node( x, y, z, w ) {

InputNode.call( this, 'v4' );

this.value = x instanceof THREE.Vector4 ? x : new THREE.Vector4( x, y, z, w );
this.value = x instanceof Vector4 ? x : new Vector4( x, y, z, w );

}

Expand Down
Loading