Skip to content

Commit 533ea51

Browse files
committed
tree shaking - dev
1 parent 774fced commit 533ea51

34 files changed

+697
-143
lines changed

examples/jsm/nodes/loaders/NodeLoader.js renamed to examples/jsm/loaders/NodeLoader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createNodeFromType } from '../core/Node.js';
2-
import { nodeObject } from '../shadernode/ShaderNode.js';
1+
import { createNodeFromType } from '../nodes/core/Node.js';
2+
import { nodeObject } from '../nodes/shadernode/ShaderNode.js';
33
import { FileLoader, Loader } from 'three';
44

55
class NodeLoader extends Loader {
File renamed without changes.
File renamed without changes.

examples/jsm/nodes/materials/Materials.js renamed to examples/jsm/materials/Materials.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports
22

33
export { default as NodeMaterial, addNodeMaterial, createNodeMaterialFromType } from './NodeMaterial.js';
4+
/*
45
export { default as InstancedPointsNodeMaterial } from './InstancedPointsNodeMaterial.js';
56
export { default as LineBasicNodeMaterial } from './LineBasicNodeMaterial.js';
67
export { default as LineDashedNodeMaterial } from './LineDashedNodeMaterial.js';
@@ -17,3 +18,4 @@ export { default as MeshMatcapNodeMaterial } from './MeshMatcapNodeMaterial.js';
1718
export { default as PointsNodeMaterial } from './PointsNodeMaterial.js';
1819
export { default as SpriteNodeMaterial } from './SpriteNodeMaterial.js';
1920
export { default as ShadowNodeMaterial } from './ShadowNodeMaterial.js';
21+
*/
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import NodeMaterial from './NodeMaterial.js';
2+
import { MultiplyOperation } from '../../../src/constants.js';
3+
import { Color } from '../../../src/math/Color.js';
4+
import { Euler } from '../../../src/math/Euler.js';
5+
6+
class MeshBasicMaterial extends NodeMaterial {
7+
8+
constructor( parameters ) {
9+
10+
super();
11+
12+
this.isMeshBasicMaterial = true;
13+
14+
this.color = new Color( 0xffffff ); // emissive
15+
16+
this.map = null;
17+
18+
this.lightMap = null;
19+
this.lightMapIntensity = 1.0;
20+
21+
this.aoMap = null;
22+
this.aoMapIntensity = 1.0;
23+
24+
this.specularMap = null;
25+
26+
this.alphaMap = null;
27+
28+
this.envMap = null;
29+
this.envMapRotation = new Euler();
30+
this.combine = MultiplyOperation;
31+
this.reflectivity = 1;
32+
this.refractionRatio = 0.98;
33+
34+
this.wireframe = false;
35+
this.wireframeLinewidth = 1;
36+
this.wireframeLinecap = 'round';
37+
this.wireframeLinejoin = 'round';
38+
39+
this.fog = true;
40+
41+
this.setValues( parameters );
42+
43+
}
44+
45+
copy( source ) {
46+
47+
super.copy( source );
48+
49+
this.color.copy( source.color );
50+
51+
this.map = source.map;
52+
53+
this.lightMap = source.lightMap;
54+
this.lightMapIntensity = source.lightMapIntensity;
55+
56+
this.aoMap = source.aoMap;
57+
this.aoMapIntensity = source.aoMapIntensity;
58+
59+
this.specularMap = source.specularMap;
60+
61+
this.alphaMap = source.alphaMap;
62+
63+
this.envMap = source.envMap;
64+
this.envMapRotation.copy( source.envMapRotation );
65+
this.combine = source.combine;
66+
this.reflectivity = source.reflectivity;
67+
this.refractionRatio = source.refractionRatio;
68+
69+
this.wireframe = source.wireframe;
70+
this.wireframeLinewidth = source.wireframeLinewidth;
71+
this.wireframeLinecap = source.wireframeLinecap;
72+
this.wireframeLinejoin = source.wireframeLinejoin;
73+
74+
this.fog = source.fog;
75+
76+
return this;
77+
78+
}
79+
80+
}
81+
82+
export default MeshBasicMaterial;
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import NodeMaterial from './NodeMaterial.js';
2+
import { MultiplyOperation, TangentSpaceNormalMap } from '../../../src/constants.js';
3+
import { Vector2 } from '../../../src/math/Vector2.js';
4+
import { Color } from '../../../src/math/Color.js';
5+
import { Euler } from '../../../src/math/Euler.js';
6+
7+
import {
8+
shininess, specularColor,
9+
materialShininess, materialSpecular
10+
} from '../nodes/Nodes.js';
11+
12+
import PhongLightingModel from '../nodes/functions/PhongLightingModel.js';
13+
14+
class MeshPhongMaterial extends NodeMaterial {
15+
16+
constructor( parameters ) {
17+
18+
super();
19+
20+
this.isMeshPhongMaterial = true;
21+
22+
this.color = new Color( 0xffffff ); // diffuse
23+
this.specular = new Color( 0x111111 );
24+
this.shininess = 30;
25+
26+
this.map = null;
27+
28+
this.lightMap = null;
29+
this.lightMapIntensity = 1.0;
30+
31+
this.aoMap = null;
32+
this.aoMapIntensity = 1.0;
33+
34+
this.emissive = new Color( 0x000000 );
35+
this.emissiveIntensity = 1.0;
36+
this.emissiveMap = null;
37+
38+
this.bumpMap = null;
39+
this.bumpScale = 1;
40+
41+
this.normalMap = null;
42+
this.normalMapType = TangentSpaceNormalMap;
43+
this.normalScale = new Vector2( 1, 1 );
44+
45+
this.displacementMap = null;
46+
this.displacementScale = 1;
47+
this.displacementBias = 0;
48+
49+
this.specularMap = null;
50+
51+
this.alphaMap = null;
52+
53+
this.envMap = null;
54+
this.envMapRotation = new Euler();
55+
this.combine = MultiplyOperation;
56+
this.reflectivity = 1;
57+
this.refractionRatio = 0.98;
58+
59+
this.wireframe = false;
60+
this.wireframeLinewidth = 1;
61+
this.wireframeLinecap = 'round';
62+
this.wireframeLinejoin = 'round';
63+
64+
this.flatShading = false;
65+
66+
this.fog = true;
67+
68+
this.lights = true;
69+
70+
this.setValues( parameters );
71+
72+
}
73+
74+
setupLightingModel( /*builder*/ ) {
75+
76+
return new PhongLightingModel();
77+
78+
}
79+
80+
setupVariants() {
81+
82+
shininess.assign( materialShininess.max( 1e-4 ) ); // to prevent pow( 0.0, 0.0 ) );
83+
specularColor.assign( materialSpecular );
84+
85+
}
86+
87+
copy( source ) {
88+
89+
super.copy( source );
90+
91+
this.color.copy( source.color );
92+
this.specular.copy( source.specular );
93+
this.shininess = source.shininess;
94+
95+
this.map = source.map;
96+
97+
this.lightMap = source.lightMap;
98+
this.lightMapIntensity = source.lightMapIntensity;
99+
100+
this.aoMap = source.aoMap;
101+
this.aoMapIntensity = source.aoMapIntensity;
102+
103+
this.emissive.copy( source.emissive );
104+
this.emissiveMap = source.emissiveMap;
105+
this.emissiveIntensity = source.emissiveIntensity;
106+
107+
this.bumpMap = source.bumpMap;
108+
this.bumpScale = source.bumpScale;
109+
110+
this.normalMap = source.normalMap;
111+
this.normalMapType = source.normalMapType;
112+
this.normalScale.copy( source.normalScale );
113+
114+
this.displacementMap = source.displacementMap;
115+
this.displacementScale = source.displacementScale;
116+
this.displacementBias = source.displacementBias;
117+
118+
this.specularMap = source.specularMap;
119+
120+
this.alphaMap = source.alphaMap;
121+
122+
this.envMap = source.envMap;
123+
this.envMapRotation.copy( source.envMapRotation );
124+
this.combine = source.combine;
125+
this.reflectivity = source.reflectivity;
126+
this.refractionRatio = source.refractionRatio;
127+
128+
this.wireframe = source.wireframe;
129+
this.wireframeLinewidth = source.wireframeLinewidth;
130+
this.wireframeLinecap = source.wireframeLinecap;
131+
this.wireframeLinejoin = source.wireframeLinejoin;
132+
133+
this.flatShading = source.flatShading;
134+
135+
this.fog = source.fog;
136+
137+
return this;
138+
139+
}
140+
141+
}
142+
143+
export default MeshPhongMaterial;

0 commit comments

Comments
 (0)