From 584bfa221b9bcc6e876fc15f992cb614a2accb09 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Sun, 24 Mar 2019 22:29:27 -0700 Subject: [PATCH 1/4] JSM: Nodes --- examples/{js => jsm}/nodes/Nodes.js | 0 examples/{js => jsm}/nodes/THREE.Nodes.js | 0 .../{js => jsm}/nodes/accessors/CameraNode.js | 0 .../{js => jsm}/nodes/accessors/ColorsNode.js | 0 .../{js => jsm}/nodes/accessors/LightNode.js | 0 .../{js => jsm}/nodes/accessors/NormalNode.js | 0 .../nodes/accessors/PositionNode.js | 0 .../nodes/accessors/ReflectNode.js | 0 .../nodes/accessors/ResolutionNode.js | 0 .../nodes/accessors/ScreenUVNode.js | 0 .../{js => jsm}/nodes/accessors/UVNode.js | 0 .../bsdfs/BlinnExponentToRoughnessNode.js | 0 .../nodes/bsdfs/BlinnShininessExponentNode.js | 0 .../bsdfs/RoughnessToBlinnExponentNode.js | 0 .../{js => jsm}/nodes/core/AttributeNode.js | 0 examples/{js => jsm}/nodes/core/ConstNode.js | 0 .../{js => jsm}/nodes/core/ExpressionNode.js | 0 .../nodes/core/FunctionCallNode.js | 0 .../{js => jsm}/nodes/core/FunctionNode.js | 0 examples/{js => jsm}/nodes/core/InputNode.js | 0 examples/{js => jsm}/nodes/core/Node.js | 6 ++++- .../{js => jsm}/nodes/core/NodeBuilder.js | 23 +++++++++++----- examples/{js => jsm}/nodes/core/NodeFrame.js | 0 examples/{js => jsm}/nodes/core/NodeLib.js | 0 .../{js => jsm}/nodes/core/NodeUniform.js | 0 examples/{js => jsm}/nodes/core/NodeUtils.js | 0 examples/{js => jsm}/nodes/core/StructNode.js | 0 examples/{js => jsm}/nodes/core/TempNode.js | 6 ++++- examples/{js => jsm}/nodes/core/VarNode.js | 0 .../{js => jsm}/nodes/effects/BlurNode.js | 6 ++++- .../nodes/effects/ColorAdjustmentNode.js | 0 .../nodes/effects/LuminanceNode.js | 0 examples/{js => jsm}/nodes/inputs/BoolNode.js | 0 .../{js => jsm}/nodes/inputs/ColorNode.js | 6 ++++- .../nodes/inputs/CubeTextureNode.js | 0 .../{js => jsm}/nodes/inputs/FloatNode.js | 0 examples/{js => jsm}/nodes/inputs/IntNode.js | 0 .../{js => jsm}/nodes/inputs/Matrix3Node.js | 6 ++++- .../{js => jsm}/nodes/inputs/Matrix4Node.js | 6 ++++- .../{js => jsm}/nodes/inputs/PropertyNode.js | 0 examples/{js => jsm}/nodes/inputs/RTTNode.js | 25 +++++++++++------ .../{js => jsm}/nodes/inputs/ReflectorNode.js | 0 .../{js => jsm}/nodes/inputs/ScreenNode.js | 0 .../{js => jsm}/nodes/inputs/TextureNode.js | 0 .../{js => jsm}/nodes/inputs/Vector2Node.js | 6 ++++- .../{js => jsm}/nodes/inputs/Vector3Node.js | 6 ++++- .../{js => jsm}/nodes/inputs/Vector4Node.js | 6 ++++- .../materials/MeshStandardNodeMaterial.js | 0 .../nodes/materials/NodeMaterial.js | 22 ++++++++++----- .../nodes/materials/PhongNodeMaterial.js | 0 .../nodes/materials/SpriteNodeMaterial.js | 0 .../nodes/materials/StandardNodeMaterial.js | 0 .../nodes/materials/nodes/MeshStandardNode.js | 9 +++++-- .../nodes/materials/nodes/PhongNode.js | 14 +++++++--- .../nodes/materials/nodes/RawNode.js | 0 .../nodes/materials/nodes/SpriteNode.js | 9 +++++-- .../nodes/materials/nodes/StandardNode.js | 11 +++++--- examples/{js => jsm}/nodes/math/CondNode.js | 0 examples/{js => jsm}/nodes/math/Math1Node.js | 0 examples/{js => jsm}/nodes/math/Math2Node.js | 0 examples/{js => jsm}/nodes/math/Math3Node.js | 0 .../{js => jsm}/nodes/math/OperatorNode.js | 0 .../{js => jsm}/nodes/misc/BumpMapNode.js | 0 .../{js => jsm}/nodes/misc/NormalMapNode.js | 0 .../{js => jsm}/nodes/misc/TextureCubeNode.js | 0 .../nodes/misc/TextureCubeUVNode.js | 0 .../nodes/postprocessing/NodePass.js | 13 ++++++--- .../postprocessing/NodePostProcessing.js | 27 +++++++++++++------ .../nodes/procedural/CheckerNode.js | 0 .../{js => jsm}/nodes/procedural/NoiseNode.js | 0 .../{js => jsm}/nodes/utils/BypassNode.js | 0 .../{js => jsm}/nodes/utils/ColorSpaceNode.js | 24 ++++++++++++----- examples/{js => jsm}/nodes/utils/JoinNode.js | 0 .../nodes/utils/MaxMIPLevelNode.js | 0 .../{js => jsm}/nodes/utils/SwitchNode.js | 0 examples/{js => jsm}/nodes/utils/TimerNode.js | 0 .../nodes/utils/UVTransformNode.js | 0 .../{js => jsm}/nodes/utils/VelocityNode.js | 18 ++++++++----- utils/modularize.js | 12 ++++----- 79 files changed, 187 insertions(+), 74 deletions(-) rename examples/{js => jsm}/nodes/Nodes.js (100%) rename examples/{js => jsm}/nodes/THREE.Nodes.js (100%) rename examples/{js => jsm}/nodes/accessors/CameraNode.js (100%) rename examples/{js => jsm}/nodes/accessors/ColorsNode.js (100%) rename examples/{js => jsm}/nodes/accessors/LightNode.js (100%) rename examples/{js => jsm}/nodes/accessors/NormalNode.js (100%) rename examples/{js => jsm}/nodes/accessors/PositionNode.js (100%) rename examples/{js => jsm}/nodes/accessors/ReflectNode.js (100%) rename examples/{js => jsm}/nodes/accessors/ResolutionNode.js (100%) rename examples/{js => jsm}/nodes/accessors/ScreenUVNode.js (100%) rename examples/{js => jsm}/nodes/accessors/UVNode.js (100%) rename examples/{js => jsm}/nodes/bsdfs/BlinnExponentToRoughnessNode.js (100%) rename examples/{js => jsm}/nodes/bsdfs/BlinnShininessExponentNode.js (100%) rename examples/{js => jsm}/nodes/bsdfs/RoughnessToBlinnExponentNode.js (100%) rename examples/{js => jsm}/nodes/core/AttributeNode.js (100%) rename examples/{js => jsm}/nodes/core/ConstNode.js (100%) rename examples/{js => jsm}/nodes/core/ExpressionNode.js (100%) rename examples/{js => jsm}/nodes/core/FunctionCallNode.js (100%) rename examples/{js => jsm}/nodes/core/FunctionNode.js (100%) rename examples/{js => jsm}/nodes/core/InputNode.js (100%) rename examples/{js => jsm}/nodes/core/Node.js (96%) rename examples/{js => jsm}/nodes/core/NodeBuilder.js (97%) rename examples/{js => jsm}/nodes/core/NodeFrame.js (100%) rename examples/{js => jsm}/nodes/core/NodeLib.js (100%) rename examples/{js => jsm}/nodes/core/NodeUniform.js (100%) rename examples/{js => jsm}/nodes/core/NodeUtils.js (100%) rename examples/{js => jsm}/nodes/core/StructNode.js (100%) rename examples/{js => jsm}/nodes/core/TempNode.js (96%) rename examples/{js => jsm}/nodes/core/VarNode.js (100%) rename examples/{js => jsm}/nodes/effects/BlurNode.js (96%) rename examples/{js => jsm}/nodes/effects/ColorAdjustmentNode.js (100%) rename examples/{js => jsm}/nodes/effects/LuminanceNode.js (100%) rename examples/{js => jsm}/nodes/inputs/BoolNode.js (100%) rename examples/{js => jsm}/nodes/inputs/ColorNode.js (88%) rename examples/{js => jsm}/nodes/inputs/CubeTextureNode.js (100%) rename examples/{js => jsm}/nodes/inputs/FloatNode.js (100%) rename examples/{js => jsm}/nodes/inputs/IntNode.js (100%) rename examples/{js => jsm}/nodes/inputs/Matrix3Node.js (91%) rename examples/{js => jsm}/nodes/inputs/Matrix4Node.js (91%) rename examples/{js => jsm}/nodes/inputs/PropertyNode.js (100%) rename examples/{js => jsm}/nodes/inputs/RTTNode.js (81%) rename examples/{js => jsm}/nodes/inputs/ReflectorNode.js (100%) rename examples/{js => jsm}/nodes/inputs/ScreenNode.js (100%) rename examples/{js => jsm}/nodes/inputs/TextureNode.js (100%) rename examples/{js => jsm}/nodes/inputs/Vector2Node.js (89%) rename examples/{js => jsm}/nodes/inputs/Vector3Node.js (89%) rename examples/{js => jsm}/nodes/inputs/Vector4Node.js (89%) rename examples/{js => jsm}/nodes/materials/MeshStandardNodeMaterial.js (100%) rename examples/{js => jsm}/nodes/materials/NodeMaterial.js (89%) rename examples/{js => jsm}/nodes/materials/PhongNodeMaterial.js (100%) rename examples/{js => jsm}/nodes/materials/SpriteNodeMaterial.js (100%) rename examples/{js => jsm}/nodes/materials/StandardNodeMaterial.js (100%) rename examples/{js => jsm}/nodes/materials/nodes/MeshStandardNode.js (95%) rename examples/{js => jsm}/nodes/materials/nodes/PhongNode.js (97%) rename examples/{js => jsm}/nodes/materials/nodes/RawNode.js (100%) rename examples/{js => jsm}/nodes/materials/nodes/SpriteNode.js (96%) rename examples/{js => jsm}/nodes/materials/nodes/StandardNode.js (98%) rename examples/{js => jsm}/nodes/math/CondNode.js (100%) rename examples/{js => jsm}/nodes/math/Math1Node.js (100%) rename examples/{js => jsm}/nodes/math/Math2Node.js (100%) rename examples/{js => jsm}/nodes/math/Math3Node.js (100%) rename examples/{js => jsm}/nodes/math/OperatorNode.js (100%) rename examples/{js => jsm}/nodes/misc/BumpMapNode.js (100%) rename examples/{js => jsm}/nodes/misc/NormalMapNode.js (100%) rename examples/{js => jsm}/nodes/misc/TextureCubeNode.js (100%) rename examples/{js => jsm}/nodes/misc/TextureCubeUVNode.js (100%) rename examples/{js => jsm}/nodes/postprocessing/NodePass.js (84%) rename examples/{js => jsm}/nodes/postprocessing/NodePostProcessing.js (79%) rename examples/{js => jsm}/nodes/procedural/CheckerNode.js (100%) rename examples/{js => jsm}/nodes/procedural/NoiseNode.js (100%) rename examples/{js => jsm}/nodes/utils/BypassNode.js (100%) rename examples/{js => jsm}/nodes/utils/ColorSpaceNode.js (96%) rename examples/{js => jsm}/nodes/utils/JoinNode.js (100%) rename examples/{js => jsm}/nodes/utils/MaxMIPLevelNode.js (100%) rename examples/{js => jsm}/nodes/utils/SwitchNode.js (100%) rename examples/{js => jsm}/nodes/utils/TimerNode.js (100%) rename examples/{js => jsm}/nodes/utils/UVTransformNode.js (100%) rename examples/{js => jsm}/nodes/utils/VelocityNode.js (91%) diff --git a/examples/js/nodes/Nodes.js b/examples/jsm/nodes/Nodes.js similarity index 100% rename from examples/js/nodes/Nodes.js rename to examples/jsm/nodes/Nodes.js diff --git a/examples/js/nodes/THREE.Nodes.js b/examples/jsm/nodes/THREE.Nodes.js similarity index 100% rename from examples/js/nodes/THREE.Nodes.js rename to examples/jsm/nodes/THREE.Nodes.js diff --git a/examples/js/nodes/accessors/CameraNode.js b/examples/jsm/nodes/accessors/CameraNode.js similarity index 100% rename from examples/js/nodes/accessors/CameraNode.js rename to examples/jsm/nodes/accessors/CameraNode.js diff --git a/examples/js/nodes/accessors/ColorsNode.js b/examples/jsm/nodes/accessors/ColorsNode.js similarity index 100% rename from examples/js/nodes/accessors/ColorsNode.js rename to examples/jsm/nodes/accessors/ColorsNode.js diff --git a/examples/js/nodes/accessors/LightNode.js b/examples/jsm/nodes/accessors/LightNode.js similarity index 100% rename from examples/js/nodes/accessors/LightNode.js rename to examples/jsm/nodes/accessors/LightNode.js diff --git a/examples/js/nodes/accessors/NormalNode.js b/examples/jsm/nodes/accessors/NormalNode.js similarity index 100% rename from examples/js/nodes/accessors/NormalNode.js rename to examples/jsm/nodes/accessors/NormalNode.js diff --git a/examples/js/nodes/accessors/PositionNode.js b/examples/jsm/nodes/accessors/PositionNode.js similarity index 100% rename from examples/js/nodes/accessors/PositionNode.js rename to examples/jsm/nodes/accessors/PositionNode.js diff --git a/examples/js/nodes/accessors/ReflectNode.js b/examples/jsm/nodes/accessors/ReflectNode.js similarity index 100% rename from examples/js/nodes/accessors/ReflectNode.js rename to examples/jsm/nodes/accessors/ReflectNode.js diff --git a/examples/js/nodes/accessors/ResolutionNode.js b/examples/jsm/nodes/accessors/ResolutionNode.js similarity index 100% rename from examples/js/nodes/accessors/ResolutionNode.js rename to examples/jsm/nodes/accessors/ResolutionNode.js diff --git a/examples/js/nodes/accessors/ScreenUVNode.js b/examples/jsm/nodes/accessors/ScreenUVNode.js similarity index 100% rename from examples/js/nodes/accessors/ScreenUVNode.js rename to examples/jsm/nodes/accessors/ScreenUVNode.js diff --git a/examples/js/nodes/accessors/UVNode.js b/examples/jsm/nodes/accessors/UVNode.js similarity index 100% rename from examples/js/nodes/accessors/UVNode.js rename to examples/jsm/nodes/accessors/UVNode.js diff --git a/examples/js/nodes/bsdfs/BlinnExponentToRoughnessNode.js b/examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.js similarity index 100% rename from examples/js/nodes/bsdfs/BlinnExponentToRoughnessNode.js rename to examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.js diff --git a/examples/js/nodes/bsdfs/BlinnShininessExponentNode.js b/examples/jsm/nodes/bsdfs/BlinnShininessExponentNode.js similarity index 100% rename from examples/js/nodes/bsdfs/BlinnShininessExponentNode.js rename to examples/jsm/nodes/bsdfs/BlinnShininessExponentNode.js diff --git a/examples/js/nodes/bsdfs/RoughnessToBlinnExponentNode.js b/examples/jsm/nodes/bsdfs/RoughnessToBlinnExponentNode.js similarity index 100% rename from examples/js/nodes/bsdfs/RoughnessToBlinnExponentNode.js rename to examples/jsm/nodes/bsdfs/RoughnessToBlinnExponentNode.js diff --git a/examples/js/nodes/core/AttributeNode.js b/examples/jsm/nodes/core/AttributeNode.js similarity index 100% rename from examples/js/nodes/core/AttributeNode.js rename to examples/jsm/nodes/core/AttributeNode.js diff --git a/examples/js/nodes/core/ConstNode.js b/examples/jsm/nodes/core/ConstNode.js similarity index 100% rename from examples/js/nodes/core/ConstNode.js rename to examples/jsm/nodes/core/ConstNode.js diff --git a/examples/js/nodes/core/ExpressionNode.js b/examples/jsm/nodes/core/ExpressionNode.js similarity index 100% rename from examples/js/nodes/core/ExpressionNode.js rename to examples/jsm/nodes/core/ExpressionNode.js diff --git a/examples/js/nodes/core/FunctionCallNode.js b/examples/jsm/nodes/core/FunctionCallNode.js similarity index 100% rename from examples/js/nodes/core/FunctionCallNode.js rename to examples/jsm/nodes/core/FunctionCallNode.js diff --git a/examples/js/nodes/core/FunctionNode.js b/examples/jsm/nodes/core/FunctionNode.js similarity index 100% rename from examples/js/nodes/core/FunctionNode.js rename to examples/jsm/nodes/core/FunctionNode.js diff --git a/examples/js/nodes/core/InputNode.js b/examples/jsm/nodes/core/InputNode.js similarity index 100% rename from examples/js/nodes/core/InputNode.js rename to examples/jsm/nodes/core/InputNode.js diff --git a/examples/js/nodes/core/Node.js b/examples/jsm/nodes/core/Node.js similarity index 96% rename from examples/js/nodes/core/Node.js rename to examples/jsm/nodes/core/Node.js index f52dd9e04d701d..e6a97c24d650b2 100644 --- a/examples/js/nodes/core/Node.js +++ b/examples/jsm/nodes/core/Node.js @@ -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 = ""; diff --git a/examples/js/nodes/core/NodeBuilder.js b/examples/jsm/nodes/core/NodeBuilder.js similarity index 97% rename from examples/js/nodes/core/NodeBuilder.js rename to examples/jsm/nodes/core/NodeBuilder.js index d80a961fa39764..69607e02caaf41 100644 --- a/examples/js/nodes/core/NodeBuilder.js +++ b/examples/jsm/nodes/core/NodeBuilder.js @@ -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'; @@ -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 ) ); @@ -939,7 +948,7 @@ NodeBuilder.prototype = { if ( ! map ) { - encoding = THREE.LinearEncoding; + encoding = LinearEncoding; } else if ( map.isTexture ) { @@ -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; } diff --git a/examples/js/nodes/core/NodeFrame.js b/examples/jsm/nodes/core/NodeFrame.js similarity index 100% rename from examples/js/nodes/core/NodeFrame.js rename to examples/jsm/nodes/core/NodeFrame.js diff --git a/examples/js/nodes/core/NodeLib.js b/examples/jsm/nodes/core/NodeLib.js similarity index 100% rename from examples/js/nodes/core/NodeLib.js rename to examples/jsm/nodes/core/NodeLib.js diff --git a/examples/js/nodes/core/NodeUniform.js b/examples/jsm/nodes/core/NodeUniform.js similarity index 100% rename from examples/js/nodes/core/NodeUniform.js rename to examples/jsm/nodes/core/NodeUniform.js diff --git a/examples/js/nodes/core/NodeUtils.js b/examples/jsm/nodes/core/NodeUtils.js similarity index 100% rename from examples/js/nodes/core/NodeUtils.js rename to examples/jsm/nodes/core/NodeUtils.js diff --git a/examples/js/nodes/core/StructNode.js b/examples/jsm/nodes/core/StructNode.js similarity index 100% rename from examples/js/nodes/core/StructNode.js rename to examples/jsm/nodes/core/StructNode.js diff --git a/examples/js/nodes/core/TempNode.js b/examples/jsm/nodes/core/TempNode.js similarity index 96% rename from examples/js/nodes/core/TempNode.js rename to examples/jsm/nodes/core/TempNode.js index 7fb4f5c8053aaf..98e6e11086fe09 100644 --- a/examples/js/nodes/core/TempNode.js +++ b/examples/jsm/nodes/core/TempNode.js @@ -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 ) { @@ -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(); } diff --git a/examples/js/nodes/core/VarNode.js b/examples/jsm/nodes/core/VarNode.js similarity index 100% rename from examples/js/nodes/core/VarNode.js rename to examples/jsm/nodes/core/VarNode.js diff --git a/examples/js/nodes/effects/BlurNode.js b/examples/jsm/nodes/effects/BlurNode.js similarity index 96% rename from examples/js/nodes/effects/BlurNode.js rename to examples/jsm/nodes/effects/BlurNode.js index 80c8d4b5769998..64cca31c466811 100644 --- a/examples/js/nodes/effects/BlurNode.js +++ b/examples/jsm/nodes/effects/BlurNode.js @@ -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'; @@ -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; diff --git a/examples/js/nodes/effects/ColorAdjustmentNode.js b/examples/jsm/nodes/effects/ColorAdjustmentNode.js similarity index 100% rename from examples/js/nodes/effects/ColorAdjustmentNode.js rename to examples/jsm/nodes/effects/ColorAdjustmentNode.js diff --git a/examples/js/nodes/effects/LuminanceNode.js b/examples/jsm/nodes/effects/LuminanceNode.js similarity index 100% rename from examples/js/nodes/effects/LuminanceNode.js rename to examples/jsm/nodes/effects/LuminanceNode.js diff --git a/examples/js/nodes/inputs/BoolNode.js b/examples/jsm/nodes/inputs/BoolNode.js similarity index 100% rename from examples/js/nodes/inputs/BoolNode.js rename to examples/jsm/nodes/inputs/BoolNode.js diff --git a/examples/js/nodes/inputs/ColorNode.js b/examples/jsm/nodes/inputs/ColorNode.js similarity index 88% rename from examples/js/nodes/inputs/ColorNode.js rename to examples/jsm/nodes/inputs/ColorNode.js index 81413c23aebd4a..58dd5efd6af840 100644 --- a/examples/js/nodes/inputs/ColorNode.js +++ b/examples/jsm/nodes/inputs/ColorNode.js @@ -2,6 +2,10 @@ * @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'; @@ -9,7 +13,7 @@ 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 ); } diff --git a/examples/js/nodes/inputs/CubeTextureNode.js b/examples/jsm/nodes/inputs/CubeTextureNode.js similarity index 100% rename from examples/js/nodes/inputs/CubeTextureNode.js rename to examples/jsm/nodes/inputs/CubeTextureNode.js diff --git a/examples/js/nodes/inputs/FloatNode.js b/examples/jsm/nodes/inputs/FloatNode.js similarity index 100% rename from examples/js/nodes/inputs/FloatNode.js rename to examples/jsm/nodes/inputs/FloatNode.js diff --git a/examples/js/nodes/inputs/IntNode.js b/examples/jsm/nodes/inputs/IntNode.js similarity index 100% rename from examples/js/nodes/inputs/IntNode.js rename to examples/jsm/nodes/inputs/IntNode.js diff --git a/examples/js/nodes/inputs/Matrix3Node.js b/examples/jsm/nodes/inputs/Matrix3Node.js similarity index 91% rename from examples/js/nodes/inputs/Matrix3Node.js rename to examples/jsm/nodes/inputs/Matrix3Node.js index 25799d20f9e7d0..ecb0591bda91a5 100644 --- a/examples/js/nodes/inputs/Matrix3Node.js +++ b/examples/jsm/nodes/inputs/Matrix3Node.js @@ -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(); } diff --git a/examples/js/nodes/inputs/Matrix4Node.js b/examples/jsm/nodes/inputs/Matrix4Node.js similarity index 91% rename from examples/js/nodes/inputs/Matrix4Node.js rename to examples/jsm/nodes/inputs/Matrix4Node.js index 50c0084f996d32..6428d4f4f0ca65 100644 --- a/examples/js/nodes/inputs/Matrix4Node.js +++ b/examples/jsm/nodes/inputs/Matrix4Node.js @@ -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(); } diff --git a/examples/js/nodes/inputs/PropertyNode.js b/examples/jsm/nodes/inputs/PropertyNode.js similarity index 100% rename from examples/js/nodes/inputs/PropertyNode.js rename to examples/jsm/nodes/inputs/PropertyNode.js diff --git a/examples/js/nodes/inputs/RTTNode.js b/examples/jsm/nodes/inputs/RTTNode.js similarity index 81% rename from examples/js/nodes/inputs/RTTNode.js rename to examples/jsm/nodes/inputs/RTTNode.js index b6065b50e9ff27..0555837be7407f 100644 --- a/examples/js/nodes/inputs/RTTNode.js +++ b/examples/jsm/nodes/inputs/RTTNode.js @@ -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'; @@ -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 ); @@ -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; @@ -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 ); @@ -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; diff --git a/examples/js/nodes/inputs/ReflectorNode.js b/examples/jsm/nodes/inputs/ReflectorNode.js similarity index 100% rename from examples/js/nodes/inputs/ReflectorNode.js rename to examples/jsm/nodes/inputs/ReflectorNode.js diff --git a/examples/js/nodes/inputs/ScreenNode.js b/examples/jsm/nodes/inputs/ScreenNode.js similarity index 100% rename from examples/js/nodes/inputs/ScreenNode.js rename to examples/jsm/nodes/inputs/ScreenNode.js diff --git a/examples/js/nodes/inputs/TextureNode.js b/examples/jsm/nodes/inputs/TextureNode.js similarity index 100% rename from examples/js/nodes/inputs/TextureNode.js rename to examples/jsm/nodes/inputs/TextureNode.js diff --git a/examples/js/nodes/inputs/Vector2Node.js b/examples/jsm/nodes/inputs/Vector2Node.js similarity index 89% rename from examples/js/nodes/inputs/Vector2Node.js rename to examples/jsm/nodes/inputs/Vector2Node.js index ebc4add3ae74b1..1a1d88b77a15f8 100644 --- a/examples/js/nodes/inputs/Vector2Node.js +++ b/examples/jsm/nodes/inputs/Vector2Node.js @@ -2,6 +2,10 @@ * @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'; @@ -9,7 +13,7 @@ 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 ); } diff --git a/examples/js/nodes/inputs/Vector3Node.js b/examples/jsm/nodes/inputs/Vector3Node.js similarity index 89% rename from examples/js/nodes/inputs/Vector3Node.js rename to examples/jsm/nodes/inputs/Vector3Node.js index 71554d0f2782b8..d233ec1011eb08 100644 --- a/examples/js/nodes/inputs/Vector3Node.js +++ b/examples/jsm/nodes/inputs/Vector3Node.js @@ -2,6 +2,10 @@ * @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'; @@ -9,7 +13,7 @@ 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 ); } diff --git a/examples/js/nodes/inputs/Vector4Node.js b/examples/jsm/nodes/inputs/Vector4Node.js similarity index 89% rename from examples/js/nodes/inputs/Vector4Node.js rename to examples/jsm/nodes/inputs/Vector4Node.js index 7bc4a977e8829a..1193e03da6143d 100644 --- a/examples/js/nodes/inputs/Vector4Node.js +++ b/examples/jsm/nodes/inputs/Vector4Node.js @@ -2,6 +2,10 @@ * @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'; @@ -9,7 +13,7 @@ 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 ); } diff --git a/examples/js/nodes/materials/MeshStandardNodeMaterial.js b/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js similarity index 100% rename from examples/js/nodes/materials/MeshStandardNodeMaterial.js rename to examples/jsm/nodes/materials/MeshStandardNodeMaterial.js diff --git a/examples/js/nodes/materials/NodeMaterial.js b/examples/jsm/nodes/materials/NodeMaterial.js similarity index 89% rename from examples/js/nodes/materials/NodeMaterial.js rename to examples/jsm/nodes/materials/NodeMaterial.js index 3220408b4811eb..8951974cde410a 100644 --- a/examples/js/nodes/materials/NodeMaterial.js +++ b/examples/jsm/nodes/materials/NodeMaterial.js @@ -2,6 +2,14 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + FrontSide, + LessEqualDepth, + NoColors, + NormalBlending, + ShaderMaterial +} from "../../../build/three.module.js"; + import { NodeBuilder } from '../core/NodeBuilder.js'; import { ColorNode } from '../inputs/ColorNode.js'; import { PositionNode } from '../accessors/PositionNode.js'; @@ -9,7 +17,7 @@ import { RawNode } from './nodes/RawNode.js'; function NodeMaterial( vertex, fragment ) { - THREE.ShaderMaterial.call( this ); + ShaderMaterial.call( this ); var self = this; @@ -28,7 +36,7 @@ function NodeMaterial( vertex, fragment ) { } -NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype ); +NodeMaterial.prototype = Object.create( ShaderMaterial.prototype ); NodeMaterial.prototype.constructor = NodeMaterial; NodeMaterial.prototype.type = "NodeMaterial"; @@ -108,7 +116,7 @@ NodeMaterial.prototype.build = function ( params ) { this.fog = builder.requires.fog; this.lights = builder.requires.lights; - this.transparent = builder.requires.transparent || this.blending > THREE.NormalBlending; + this.transparent = builder.requires.transparent || this.blending > NormalBlending; this.needsUpdate = false; @@ -164,12 +172,12 @@ NodeMaterial.prototype.toJSON = function ( meta ) { if ( this.size !== undefined ) data.size = this.size; if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; - if ( this.blending !== THREE.NormalBlending ) data.blending = this.blending; + if ( this.blending !== NormalBlending ) data.blending = this.blending; if ( this.flatShading === true ) data.flatShading = this.flatShading; - if ( this.side !== THREE.FrontSide ) data.side = this.side; - if ( this.vertexColors !== THREE.NoColors ) data.vertexColors = this.vertexColors; + if ( this.side !== FrontSide ) data.side = this.side; + if ( this.vertexColors !== NoColors ) data.vertexColors = this.vertexColors; - if ( this.depthFunc !== THREE.LessEqualDepth ) data.depthFunc = this.depthFunc; + if ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc; if ( this.depthTest === false ) data.depthTest = this.depthTest; if ( this.depthWrite === false ) data.depthWrite = this.depthWrite; diff --git a/examples/js/nodes/materials/PhongNodeMaterial.js b/examples/jsm/nodes/materials/PhongNodeMaterial.js similarity index 100% rename from examples/js/nodes/materials/PhongNodeMaterial.js rename to examples/jsm/nodes/materials/PhongNodeMaterial.js diff --git a/examples/js/nodes/materials/SpriteNodeMaterial.js b/examples/jsm/nodes/materials/SpriteNodeMaterial.js similarity index 100% rename from examples/js/nodes/materials/SpriteNodeMaterial.js rename to examples/jsm/nodes/materials/SpriteNodeMaterial.js diff --git a/examples/js/nodes/materials/StandardNodeMaterial.js b/examples/jsm/nodes/materials/StandardNodeMaterial.js similarity index 100% rename from examples/js/nodes/materials/StandardNodeMaterial.js rename to examples/jsm/nodes/materials/StandardNodeMaterial.js diff --git a/examples/js/nodes/materials/nodes/MeshStandardNode.js b/examples/jsm/nodes/materials/nodes/MeshStandardNode.js similarity index 95% rename from examples/js/nodes/materials/nodes/MeshStandardNode.js rename to examples/jsm/nodes/materials/nodes/MeshStandardNode.js index 79b60e63dc793f..9f78ebdd352387 100644 --- a/examples/js/nodes/materials/nodes/MeshStandardNode.js +++ b/examples/jsm/nodes/materials/nodes/MeshStandardNode.js @@ -2,6 +2,11 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + Color, + Vector2 +} from "../../../build/three.module.js"; + import { StandardNode } from './StandardNode.js'; import { PropertyNode } from '../../inputs/PropertyNode.js'; import { OperatorNode } from '../../math/OperatorNode.js'; @@ -13,10 +18,10 @@ function MeshStandardNode() { StandardNode.call( this ); this.properties = { - color: new THREE.Color( 0xffffff ), + color: new Color( 0xffffff ), roughness: 0.5, metalness: 0.5, - normalScale: new THREE.Vector2( 1, 1 ) + normalScale: new Vector2( 1, 1 ) }; this.inputs = { diff --git a/examples/js/nodes/materials/nodes/PhongNode.js b/examples/jsm/nodes/materials/nodes/PhongNode.js similarity index 97% rename from examples/js/nodes/materials/nodes/PhongNode.js rename to examples/jsm/nodes/materials/nodes/PhongNode.js index 98a64b713bfbb0..5e2bbc3c1164ed 100644 --- a/examples/js/nodes/materials/nodes/PhongNode.js +++ b/examples/jsm/nodes/materials/nodes/PhongNode.js @@ -2,6 +2,12 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + ENVMAP_BLENDING_MULTIPLY, + UniformsLib, + UniformsUtils +} from "../../../build/three.module.js"; + import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; import { FloatNode } from '../../inputs/FloatNode.js'; @@ -32,10 +38,10 @@ PhongNode.prototype.build = function ( builder ) { var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; - builder.mergeUniform( THREE.UniformsUtils.merge( [ + builder.mergeUniform( UniformsUtils.merge( [ - THREE.UniformsLib.fog, - THREE.UniformsLib.lights + UniformsLib.fog, + UniformsLib.lights ] ) ); @@ -301,7 +307,7 @@ PhongNode.prototype.build = function ( builder ) { /* switch( builder.material.combine ) { - case THREE.ENVMAP_BLENDING_MULTIPLY: + case ENVMAP_BLENDING_MULTIPLY: //output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" ); //outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); diff --git a/examples/js/nodes/materials/nodes/RawNode.js b/examples/jsm/nodes/materials/nodes/RawNode.js similarity index 100% rename from examples/js/nodes/materials/nodes/RawNode.js rename to examples/jsm/nodes/materials/nodes/RawNode.js diff --git a/examples/js/nodes/materials/nodes/SpriteNode.js b/examples/jsm/nodes/materials/nodes/SpriteNode.js similarity index 96% rename from examples/js/nodes/materials/nodes/SpriteNode.js rename to examples/jsm/nodes/materials/nodes/SpriteNode.js index 08326fa4b436f6..3adf642b117caa 100644 --- a/examples/js/nodes/materials/nodes/SpriteNode.js +++ b/examples/jsm/nodes/materials/nodes/SpriteNode.js @@ -2,6 +2,11 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + UniformsLib, + UniformsUtils +} from "../../../build/three.module.js"; + import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; @@ -31,8 +36,8 @@ SpriteNode.prototype.build = function ( builder ) { var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; - builder.mergeUniform( THREE.UniformsUtils.merge( [ - THREE.UniformsLib.fog + builder.mergeUniform( UniformsUtils.merge( [ + UniformsLib.fog ] ) ); builder.addParsCode( [ diff --git a/examples/js/nodes/materials/nodes/StandardNode.js b/examples/jsm/nodes/materials/nodes/StandardNode.js similarity index 98% rename from examples/js/nodes/materials/nodes/StandardNode.js rename to examples/jsm/nodes/materials/nodes/StandardNode.js index bcd842a5036fc0..3c2aa094cce9c3 100644 --- a/examples/js/nodes/materials/nodes/StandardNode.js +++ b/examples/jsm/nodes/materials/nodes/StandardNode.js @@ -2,6 +2,11 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + UniformsLib, + UniformsUtils +} from "../../../build/three.module.js"; + import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; import { FloatNode } from '../../inputs/FloatNode.js'; @@ -35,10 +40,10 @@ StandardNode.prototype.build = function ( builder ) { var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; - builder.mergeUniform( THREE.UniformsUtils.merge( [ + builder.mergeUniform( UniformsUtils.merge( [ - THREE.UniformsLib.fog, - THREE.UniformsLib.lights + UniformsLib.fog, + UniformsLib.lights ] ) ); diff --git a/examples/js/nodes/math/CondNode.js b/examples/jsm/nodes/math/CondNode.js similarity index 100% rename from examples/js/nodes/math/CondNode.js rename to examples/jsm/nodes/math/CondNode.js diff --git a/examples/js/nodes/math/Math1Node.js b/examples/jsm/nodes/math/Math1Node.js similarity index 100% rename from examples/js/nodes/math/Math1Node.js rename to examples/jsm/nodes/math/Math1Node.js diff --git a/examples/js/nodes/math/Math2Node.js b/examples/jsm/nodes/math/Math2Node.js similarity index 100% rename from examples/js/nodes/math/Math2Node.js rename to examples/jsm/nodes/math/Math2Node.js diff --git a/examples/js/nodes/math/Math3Node.js b/examples/jsm/nodes/math/Math3Node.js similarity index 100% rename from examples/js/nodes/math/Math3Node.js rename to examples/jsm/nodes/math/Math3Node.js diff --git a/examples/js/nodes/math/OperatorNode.js b/examples/jsm/nodes/math/OperatorNode.js similarity index 100% rename from examples/js/nodes/math/OperatorNode.js rename to examples/jsm/nodes/math/OperatorNode.js diff --git a/examples/js/nodes/misc/BumpMapNode.js b/examples/jsm/nodes/misc/BumpMapNode.js similarity index 100% rename from examples/js/nodes/misc/BumpMapNode.js rename to examples/jsm/nodes/misc/BumpMapNode.js diff --git a/examples/js/nodes/misc/NormalMapNode.js b/examples/jsm/nodes/misc/NormalMapNode.js similarity index 100% rename from examples/js/nodes/misc/NormalMapNode.js rename to examples/jsm/nodes/misc/NormalMapNode.js diff --git a/examples/js/nodes/misc/TextureCubeNode.js b/examples/jsm/nodes/misc/TextureCubeNode.js similarity index 100% rename from examples/js/nodes/misc/TextureCubeNode.js rename to examples/jsm/nodes/misc/TextureCubeNode.js diff --git a/examples/js/nodes/misc/TextureCubeUVNode.js b/examples/jsm/nodes/misc/TextureCubeUVNode.js similarity index 100% rename from examples/js/nodes/misc/TextureCubeUVNode.js rename to examples/jsm/nodes/misc/TextureCubeUVNode.js diff --git a/examples/js/nodes/postprocessing/NodePass.js b/examples/jsm/nodes/postprocessing/NodePass.js similarity index 84% rename from examples/js/nodes/postprocessing/NodePass.js rename to examples/jsm/nodes/postprocessing/NodePass.js index f92a2a817edce4..5cf221e5031f00 100644 --- a/examples/js/nodes/postprocessing/NodePass.js +++ b/examples/jsm/nodes/postprocessing/NodePass.js @@ -2,15 +2,20 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + Math as _Math, + ShaderPass +} from "../../../build/three.module.js"; + import { NodeMaterial } from '../materials/NodeMaterial.js'; import { ScreenNode } from '../inputs/ScreenNode.js'; function NodePass() { - THREE.ShaderPass.call( this ); + ShaderPass.call( this ); this.name = ""; - this.uuid = THREE.Math.generateUUID(); + this.uuid = _Math.generateUUID(); this.userData = {}; @@ -24,7 +29,7 @@ function NodePass() { } -NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); +NodePass.prototype = Object.create( ShaderPass.prototype ); NodePass.prototype.constructor = NodePass; NodePass.prototype.render = function () { @@ -41,7 +46,7 @@ NodePass.prototype.render = function () { this.uniforms = this.material.uniforms; - THREE.ShaderPass.prototype.render.apply( this, arguments ); + ShaderPass.prototype.render.apply( this, arguments ); }; diff --git a/examples/js/nodes/postprocessing/NodePostProcessing.js b/examples/jsm/nodes/postprocessing/NodePostProcessing.js similarity index 79% rename from examples/js/nodes/postprocessing/NodePostProcessing.js rename to examples/jsm/nodes/postprocessing/NodePostProcessing.js index 26ecbe57b32fe4..362426566f89de 100644 --- a/examples/js/nodes/postprocessing/NodePostProcessing.js +++ b/examples/jsm/nodes/postprocessing/NodePostProcessing.js @@ -2,6 +2,17 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + LinearFilter, + Mesh, + OrthographicCamera, + PlaneBufferGeometry, + RGBAFormat, + Scene, + Vector2, + WebGLRenderTarget +} from "../../../build/three.module.js"; + import { NodeMaterial } from '../materials/NodeMaterial.js'; import { ScreenNode } from '../inputs/ScreenNode.js'; @@ -10,14 +21,14 @@ function NodePostProcessing( renderer, renderTarget ) { if ( renderTarget === undefined ) { var parameters = { - minFilter: THREE.LinearFilter, - magFilter: THREE.LinearFilter, - format: THREE.RGBAFormat, + minFilter: LinearFilter, + magFilter: LinearFilter, + format: RGBAFormat, stencilBuffer: false }; - var size = renderer.getDrawingBufferSize( new THREE.Vector2() ); - renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters ); + var size = renderer.getDrawingBufferSize( new Vector2() ); + renderTarget = new WebGLRenderTarget( size.width, size.height, parameters ); } @@ -27,10 +38,10 @@ function NodePostProcessing( renderer, renderTarget ) { this.output = new ScreenNode(); 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 ); diff --git a/examples/js/nodes/procedural/CheckerNode.js b/examples/jsm/nodes/procedural/CheckerNode.js similarity index 100% rename from examples/js/nodes/procedural/CheckerNode.js rename to examples/jsm/nodes/procedural/CheckerNode.js diff --git a/examples/js/nodes/procedural/NoiseNode.js b/examples/jsm/nodes/procedural/NoiseNode.js similarity index 100% rename from examples/js/nodes/procedural/NoiseNode.js rename to examples/jsm/nodes/procedural/NoiseNode.js diff --git a/examples/js/nodes/utils/BypassNode.js b/examples/jsm/nodes/utils/BypassNode.js similarity index 100% rename from examples/js/nodes/utils/BypassNode.js rename to examples/jsm/nodes/utils/BypassNode.js diff --git a/examples/js/nodes/utils/ColorSpaceNode.js b/examples/jsm/nodes/utils/ColorSpaceNode.js similarity index 96% rename from examples/js/nodes/utils/ColorSpaceNode.js rename to examples/jsm/nodes/utils/ColorSpaceNode.js index afede0b1e0dfdd..9163e2a59eb22e 100644 --- a/examples/js/nodes/utils/ColorSpaceNode.js +++ b/examples/jsm/nodes/utils/ColorSpaceNode.js @@ -2,6 +2,16 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + GammaEncoding, + LinearEncoding, + RGBDEncoding, + RGBEEncoding, + RGBM16Encoding, + RGBM7Encoding, + sRGBEncoding +} from "../../../build/three.module.js"; + import { TempNode } from '../core/TempNode.js'; import { ConstNode } from '../core/ConstNode.js'; import { FunctionNode } from '../core/FunctionNode.js'; @@ -249,19 +259,19 @@ ColorSpaceNode.prototype.getEncodingComponents = function ( encoding ) { switch ( encoding ) { - case THREE.LinearEncoding: + case LinearEncoding: return [ 'Linear' ]; - case THREE.sRGBEncoding: + case sRGBEncoding: return [ 'sRGB' ]; - case THREE.RGBEEncoding: + case RGBEEncoding: return [ 'RGBE' ]; - case THREE.RGBM7Encoding: + case RGBM7Encoding: return [ 'RGBM', '7.0' ]; - case THREE.RGBM16Encoding: + case RGBM16Encoding: return [ 'RGBM', '16.0' ]; - case THREE.RGBDEncoding: + case RGBDEncoding: return [ 'RGBD', '256.0' ]; - case THREE.GammaEncoding: + case GammaEncoding: return [ 'Gamma', 'float( GAMMA_FACTOR )' ]; } diff --git a/examples/js/nodes/utils/JoinNode.js b/examples/jsm/nodes/utils/JoinNode.js similarity index 100% rename from examples/js/nodes/utils/JoinNode.js rename to examples/jsm/nodes/utils/JoinNode.js diff --git a/examples/js/nodes/utils/MaxMIPLevelNode.js b/examples/jsm/nodes/utils/MaxMIPLevelNode.js similarity index 100% rename from examples/js/nodes/utils/MaxMIPLevelNode.js rename to examples/jsm/nodes/utils/MaxMIPLevelNode.js diff --git a/examples/js/nodes/utils/SwitchNode.js b/examples/jsm/nodes/utils/SwitchNode.js similarity index 100% rename from examples/js/nodes/utils/SwitchNode.js rename to examples/jsm/nodes/utils/SwitchNode.js diff --git a/examples/js/nodes/utils/TimerNode.js b/examples/jsm/nodes/utils/TimerNode.js similarity index 100% rename from examples/js/nodes/utils/TimerNode.js rename to examples/jsm/nodes/utils/TimerNode.js diff --git a/examples/js/nodes/utils/UVTransformNode.js b/examples/jsm/nodes/utils/UVTransformNode.js similarity index 100% rename from examples/js/nodes/utils/UVTransformNode.js rename to examples/jsm/nodes/utils/UVTransformNode.js diff --git a/examples/js/nodes/utils/VelocityNode.js b/examples/jsm/nodes/utils/VelocityNode.js similarity index 91% rename from examples/js/nodes/utils/VelocityNode.js rename to examples/jsm/nodes/utils/VelocityNode.js index 0240d81ec6b376..24de4f362bf848 100644 --- a/examples/js/nodes/utils/VelocityNode.js +++ b/examples/jsm/nodes/utils/VelocityNode.js @@ -2,6 +2,10 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + Vector3 +} from "../../../build/three.module.js"; + import { Vector3Node } from '../inputs/Vector3Node.js'; function VelocityNode( target, params ) { @@ -10,7 +14,7 @@ function VelocityNode( target, params ) { this.params = {}; - this.velocity = new THREE.Vector3(); + this.velocity = new Vector3(); this.setTarget( target ); this.setParams( params ); @@ -50,12 +54,12 @@ VelocityNode.prototype.setParams = function ( params ) { case "elastic": - this.moment = new THREE.Vector3(); + this.moment = new Vector3(); - this.speed = new THREE.Vector3(); - this.springVelocity = new THREE.Vector3(); + this.speed = new Vector3(); + this.springVelocity = new Vector3(); - this.lastVelocity = new THREE.Vector3(); + this.lastVelocity = new Vector3(); break; @@ -76,7 +80,7 @@ VelocityNode.prototype.setTarget = function ( target ) { if ( target ) { - this.position = target.getWorldPosition( this.position || new THREE.Vector3() ); + this.position = target.getWorldPosition( this.position || new Vector3() ); this.oldPosition = this.position.clone(); } @@ -87,7 +91,7 @@ VelocityNode.prototype.updateFrameVelocity = function ( frame ) { if ( this.target ) { - this.position = this.target.getWorldPosition( this.position || new THREE.Vector3() ); + this.position = this.target.getWorldPosition( this.position || new Vector3() ); this.velocity.subVectors( this.position, this.oldPosition ); this.oldPosition.copy( this.position ); diff --git a/utils/modularize.js b/utils/modularize.js index fd81784e65cd81..abc3788f0dbfd9 100644 --- a/utils/modularize.js +++ b/utils/modularize.js @@ -54,7 +54,7 @@ function convert( path, ignoreList ) { contents = contents.replace( /^\/\*+[^*]*\*+(?:[^/*][^*]*\*+)*\//, function ( match ) { - return `${match}\n\n_IMPORTS_`; + return `${match}_IMPORTS_`; } ); @@ -70,9 +70,9 @@ function convert( path, ignoreList ) { } ); - contents = contents.replace( /(\'?)THREE\.([a-zA-Z0-9]+)(\.{0,1})/g, function ( match, p1, p2, p3 ) { + contents = contents.replace( /(['"]?)THREE\.([a-zA-Z0-9]+)(\.{0,1})/g, function ( match, p1, p2, p3 ) { - if ( p1 === '\'' ) return match; // Inside a string + if ( p1 === '\'' || p1 === '"' ) return match; // Inside a string if ( p2 === className ) return `${p2}${p3}`; if ( p1 === 'Math' ) { @@ -101,10 +101,10 @@ function convert( path, ignoreList ) { // constants - contents = contents.replace( /(\'?)THREE\.([a-zA-Z0-9]+)/g, function ( match, p1, p2 ) { + contents = contents.replace( /(['"]?)?THREE\.([a-zA-Z0-9]+)/g, function ( match, p1, p2 ) { if ( ignoreList.includes( p2 ) ) return match; - if ( p1 === '\'' ) return match; // Inside a string + if ( p1 === '\'' || p1 === '"' ) return match; // Inside a string if ( p2 === className ) return p2; if ( p2 === 'Math' || p2 === '_Math' ) { @@ -131,7 +131,7 @@ function convert( path, ignoreList ) { .map( value => '\n\t' + value ) .sort() .toString(); - var imports = `import {${keys}\n} from "../../../build/three.module.js";`; + var imports = `\n\nimport {${keys}\n} from "../../../build/three.module.js";`; var exports = `export { ${className} };\n`; var output = contents.replace( '_IMPORTS_', keys ? imports : '' ) + '\n' + exports; From 032fb883f3c30b40b12888d067496de4cb89809f Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Sun, 24 Mar 2019 22:54:46 -0700 Subject: [PATCH 2/4] JSM: Fix nodes example. --- .../{js => jsm}/loaders/NodeMaterialLoader.js | 17 +- examples/jsm/nodes/core/Node.js | 2 +- examples/jsm/nodes/core/NodeBuilder.js | 2 +- examples/jsm/nodes/core/TempNode.js | 2 +- examples/jsm/nodes/effects/BlurNode.js | 2 +- examples/jsm/nodes/inputs/ColorNode.js | 2 +- examples/jsm/nodes/inputs/Matrix3Node.js | 2 +- examples/jsm/nodes/inputs/Matrix4Node.js | 2 +- examples/jsm/nodes/inputs/RTTNode.js | 2 +- examples/jsm/nodes/inputs/Vector2Node.js | 2 +- examples/jsm/nodes/inputs/Vector3Node.js | 2 +- examples/jsm/nodes/inputs/Vector4Node.js | 2 +- examples/jsm/nodes/materials/NodeMaterial.js | 2 +- .../nodes/materials/nodes/MeshStandardNode.js | 2 +- .../jsm/nodes/materials/nodes/PhongNode.js | 3 +- .../jsm/nodes/materials/nodes/SpriteNode.js | 2 +- .../jsm/nodes/materials/nodes/StandardNode.js | 2 +- examples/jsm/nodes/postprocessing/NodePass.js | 2 +- .../postprocessing/NodePostProcessing.js | 2 +- examples/jsm/nodes/utils/ColorSpaceNode.js | 2 +- examples/jsm/nodes/utils/VelocityNode.js | 2 +- examples/webgl_materials_nodes.html | 1165 +++++++++-------- 22 files changed, 640 insertions(+), 583 deletions(-) rename examples/{js => jsm}/loaders/NodeMaterialLoader.js (90%) diff --git a/examples/js/loaders/NodeMaterialLoader.js b/examples/jsm/loaders/NodeMaterialLoader.js similarity index 90% rename from examples/js/loaders/NodeMaterialLoader.js rename to examples/jsm/loaders/NodeMaterialLoader.js index db29336b1b6779..5ac88e694176e1 100644 --- a/examples/js/loaders/NodeMaterialLoader.js +++ b/examples/jsm/loaders/NodeMaterialLoader.js @@ -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 = {}; @@ -14,7 +19,7 @@ THREE.NodeMaterialLoader = function ( manager, library ) { }; -THREE.NodeMaterialLoaderUtils = { +var NodeMaterialLoaderUtils = { replaceUUIDObject: function ( object, uuid, value, recursive ) { @@ -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 ) { @@ -263,3 +268,5 @@ Object.assign( THREE.NodeMaterialLoader.prototype, { } } ); + +export { NodeMaterialLoader, NodeMaterialLoaderUtils }; diff --git a/examples/jsm/nodes/core/Node.js b/examples/jsm/nodes/core/Node.js index e6a97c24d650b2..43a48337491b06 100644 --- a/examples/jsm/nodes/core/Node.js +++ b/examples/jsm/nodes/core/Node.js @@ -4,7 +4,7 @@ import { Math as _Math -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; function Node( type ) { diff --git a/examples/jsm/nodes/core/NodeBuilder.js b/examples/jsm/nodes/core/NodeBuilder.js index 69607e02caaf41..f40cff0a572585 100644 --- a/examples/jsm/nodes/core/NodeBuilder.js +++ b/examples/jsm/nodes/core/NodeBuilder.js @@ -9,7 +9,7 @@ import { CubeUVRefractionMapping, GammaEncoding, LinearEncoding -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { NodeUniform } from './NodeUniform.js'; import { NodeUtils } from './NodeUtils.js'; diff --git a/examples/jsm/nodes/core/TempNode.js b/examples/jsm/nodes/core/TempNode.js index 98e6e11086fe09..371c88d9e3b5ac 100644 --- a/examples/jsm/nodes/core/TempNode.js +++ b/examples/jsm/nodes/core/TempNode.js @@ -5,7 +5,7 @@ import { Math as _Math -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { Node } from './Node.js'; diff --git a/examples/jsm/nodes/effects/BlurNode.js b/examples/jsm/nodes/effects/BlurNode.js index 64cca31c466811..7de82260b11894 100644 --- a/examples/jsm/nodes/effects/BlurNode.js +++ b/examples/jsm/nodes/effects/BlurNode.js @@ -4,7 +4,7 @@ import { Vector2 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { TempNode } from '../core/TempNode.js'; import { FunctionNode } from '../core/FunctionNode.js'; diff --git a/examples/jsm/nodes/inputs/ColorNode.js b/examples/jsm/nodes/inputs/ColorNode.js index 58dd5efd6af840..409fe164bbccb5 100644 --- a/examples/jsm/nodes/inputs/ColorNode.js +++ b/examples/jsm/nodes/inputs/ColorNode.js @@ -4,7 +4,7 @@ import { Color -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; import { NodeUtils } from '../core/NodeUtils.js'; diff --git a/examples/jsm/nodes/inputs/Matrix3Node.js b/examples/jsm/nodes/inputs/Matrix3Node.js index ecb0591bda91a5..39c1ed3a834449 100644 --- a/examples/jsm/nodes/inputs/Matrix3Node.js +++ b/examples/jsm/nodes/inputs/Matrix3Node.js @@ -4,7 +4,7 @@ import { Matrix3 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; diff --git a/examples/jsm/nodes/inputs/Matrix4Node.js b/examples/jsm/nodes/inputs/Matrix4Node.js index 6428d4f4f0ca65..cca0058ce01251 100644 --- a/examples/jsm/nodes/inputs/Matrix4Node.js +++ b/examples/jsm/nodes/inputs/Matrix4Node.js @@ -4,7 +4,7 @@ import { Matrix4 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; diff --git a/examples/jsm/nodes/inputs/RTTNode.js b/examples/jsm/nodes/inputs/RTTNode.js index 0555837be7407f..284418ff96765e 100644 --- a/examples/jsm/nodes/inputs/RTTNode.js +++ b/examples/jsm/nodes/inputs/RTTNode.js @@ -8,7 +8,7 @@ import { PlaneBufferGeometry, Scene, WebGLRenderTarget -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { NodeBuilder } from '../core/NodeBuilder.js'; import { NodeMaterial } from '../materials/NodeMaterial.js'; diff --git a/examples/jsm/nodes/inputs/Vector2Node.js b/examples/jsm/nodes/inputs/Vector2Node.js index 1a1d88b77a15f8..db59d25e6a0403 100644 --- a/examples/jsm/nodes/inputs/Vector2Node.js +++ b/examples/jsm/nodes/inputs/Vector2Node.js @@ -4,7 +4,7 @@ import { Vector2 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; import { NodeUtils } from '../core/NodeUtils.js'; diff --git a/examples/jsm/nodes/inputs/Vector3Node.js b/examples/jsm/nodes/inputs/Vector3Node.js index d233ec1011eb08..a803552d21685f 100644 --- a/examples/jsm/nodes/inputs/Vector3Node.js +++ b/examples/jsm/nodes/inputs/Vector3Node.js @@ -4,7 +4,7 @@ import { Vector3 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; import { NodeUtils } from '../core/NodeUtils.js'; diff --git a/examples/jsm/nodes/inputs/Vector4Node.js b/examples/jsm/nodes/inputs/Vector4Node.js index 1193e03da6143d..738f93fd42c9e7 100644 --- a/examples/jsm/nodes/inputs/Vector4Node.js +++ b/examples/jsm/nodes/inputs/Vector4Node.js @@ -4,7 +4,7 @@ import { Vector4 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { InputNode } from '../core/InputNode.js'; import { NodeUtils } from '../core/NodeUtils.js'; diff --git a/examples/jsm/nodes/materials/NodeMaterial.js b/examples/jsm/nodes/materials/NodeMaterial.js index 8951974cde410a..a1d9acea51b381 100644 --- a/examples/jsm/nodes/materials/NodeMaterial.js +++ b/examples/jsm/nodes/materials/NodeMaterial.js @@ -8,7 +8,7 @@ import { NoColors, NormalBlending, ShaderMaterial -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { NodeBuilder } from '../core/NodeBuilder.js'; import { ColorNode } from '../inputs/ColorNode.js'; diff --git a/examples/jsm/nodes/materials/nodes/MeshStandardNode.js b/examples/jsm/nodes/materials/nodes/MeshStandardNode.js index 9f78ebdd352387..0a0a4dc2f89023 100644 --- a/examples/jsm/nodes/materials/nodes/MeshStandardNode.js +++ b/examples/jsm/nodes/materials/nodes/MeshStandardNode.js @@ -5,7 +5,7 @@ import { Color, Vector2 -} from "../../../build/three.module.js"; +} from "../../../../../build/three.module.js"; import { StandardNode } from './StandardNode.js'; import { PropertyNode } from '../../inputs/PropertyNode.js'; diff --git a/examples/jsm/nodes/materials/nodes/PhongNode.js b/examples/jsm/nodes/materials/nodes/PhongNode.js index 5e2bbc3c1164ed..4dba5adb3f8632 100644 --- a/examples/jsm/nodes/materials/nodes/PhongNode.js +++ b/examples/jsm/nodes/materials/nodes/PhongNode.js @@ -3,10 +3,9 @@ */ import { - ENVMAP_BLENDING_MULTIPLY, UniformsLib, UniformsUtils -} from "../../../build/three.module.js"; +} from "../../../../../build/three.module.js"; import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; diff --git a/examples/jsm/nodes/materials/nodes/SpriteNode.js b/examples/jsm/nodes/materials/nodes/SpriteNode.js index 3adf642b117caa..183081ff4f8660 100644 --- a/examples/jsm/nodes/materials/nodes/SpriteNode.js +++ b/examples/jsm/nodes/materials/nodes/SpriteNode.js @@ -5,7 +5,7 @@ import { UniformsLib, UniformsUtils -} from "../../../build/three.module.js"; +} from "../../../../../build/three.module.js"; import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; diff --git a/examples/jsm/nodes/materials/nodes/StandardNode.js b/examples/jsm/nodes/materials/nodes/StandardNode.js index 3c2aa094cce9c3..d1dd381960b776 100644 --- a/examples/jsm/nodes/materials/nodes/StandardNode.js +++ b/examples/jsm/nodes/materials/nodes/StandardNode.js @@ -5,7 +5,7 @@ import { UniformsLib, UniformsUtils -} from "../../../build/three.module.js"; +} from "../../../../../build/three.module.js"; import { Node } from '../../core/Node.js'; import { ColorNode } from '../../inputs/ColorNode.js'; diff --git a/examples/jsm/nodes/postprocessing/NodePass.js b/examples/jsm/nodes/postprocessing/NodePass.js index 5cf221e5031f00..7191e089e3e8ac 100644 --- a/examples/jsm/nodes/postprocessing/NodePass.js +++ b/examples/jsm/nodes/postprocessing/NodePass.js @@ -5,7 +5,7 @@ import { Math as _Math, ShaderPass -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { NodeMaterial } from '../materials/NodeMaterial.js'; import { ScreenNode } from '../inputs/ScreenNode.js'; diff --git a/examples/jsm/nodes/postprocessing/NodePostProcessing.js b/examples/jsm/nodes/postprocessing/NodePostProcessing.js index 362426566f89de..0924069bf309fa 100644 --- a/examples/jsm/nodes/postprocessing/NodePostProcessing.js +++ b/examples/jsm/nodes/postprocessing/NodePostProcessing.js @@ -11,7 +11,7 @@ import { Scene, Vector2, WebGLRenderTarget -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { NodeMaterial } from '../materials/NodeMaterial.js'; import { ScreenNode } from '../inputs/ScreenNode.js'; diff --git a/examples/jsm/nodes/utils/ColorSpaceNode.js b/examples/jsm/nodes/utils/ColorSpaceNode.js index 9163e2a59eb22e..01c4016c7a8918 100644 --- a/examples/jsm/nodes/utils/ColorSpaceNode.js +++ b/examples/jsm/nodes/utils/ColorSpaceNode.js @@ -10,7 +10,7 @@ import { RGBM16Encoding, RGBM7Encoding, sRGBEncoding -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { TempNode } from '../core/TempNode.js'; import { ConstNode } from '../core/ConstNode.js'; diff --git a/examples/jsm/nodes/utils/VelocityNode.js b/examples/jsm/nodes/utils/VelocityNode.js index 24de4f362bf848..adf606b9b2b419 100644 --- a/examples/jsm/nodes/utils/VelocityNode.js +++ b/examples/jsm/nodes/utils/VelocityNode.js @@ -4,7 +4,7 @@ import { Vector3 -} from "../../../build/three.module.js"; +} from "../../../../build/three.module.js"; import { Vector3Node } from '../inputs/Vector3Node.js'; diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index fa7ce927f8e9b7..7af86ccd0e4328 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -34,21 +34,71 @@ Serialize and apply - - - - - - -