@anov/3d 0.0.288 → 0.0.290
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anov3d.js +43 -40
- package/dist/anov3d.js.map +1 -1
- package/dist/applicationApi.js +118 -94
- package/dist/applicationApi.js.map +1 -1
- package/dist/hooksManager.js +10 -10
- package/dist/hooksManager.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messageStatus.js +3 -3
- package/dist/messageStatus.js.map +1 -1
- package/dist/module/animation/index.js +113 -61
- package/dist/module/animation/index.js.map +1 -1
- package/dist/module/animation/motion/index.js +91 -58
- package/dist/module/animation/motion/index.js.map +1 -1
- package/dist/module/animation/strategy.js +21 -7
- package/dist/module/animation/strategy.js.map +1 -1
- package/dist/module/camera/index.js +278 -216
- package/dist/module/camera/index.js.map +1 -1
- package/dist/module/develop/index.js +35 -27
- package/dist/module/develop/index.js.map +1 -1
- package/dist/module/entity/area/index.js +87 -29
- package/dist/module/entity/area/index.js.map +1 -1
- package/dist/module/entity/bar/index.js +24 -5
- package/dist/module/entity/bar/index.js.map +1 -1
- package/dist/module/entity/bar/style/bar_01.js +52 -13
- package/dist/module/entity/bar/style/bar_01.js.map +1 -1
- package/dist/module/entity/bar/style/index.js +21 -7
- package/dist/module/entity/bar/style/index.js.map +1 -1
- package/dist/module/entity/baseEntity.js +66 -43
- package/dist/module/entity/baseEntity.js.map +1 -1
- package/dist/module/entity/batch/index.js +168 -77
- package/dist/module/entity/batch/index.js.map +1 -1
- package/dist/module/entity/dispose.js +16 -14
- package/dist/module/entity/dispose.js.map +1 -1
- package/dist/module/entity/flyline/index.js +90 -34
- package/dist/module/entity/flyline/index.js.map +1 -1
- package/dist/module/entity/group/index.js +75 -59
- package/dist/module/entity/group/index.js.map +1 -1
- package/dist/module/entity/heatmap/index.js +79 -62
- package/dist/module/entity/heatmap/index.js.map +1 -1
- package/dist/module/entity/hybridList.js +67 -49
- package/dist/module/entity/hybridList.js.map +1 -1
- package/dist/module/entity/index.js +644 -442
- package/dist/module/entity/index.js.map +1 -1
- package/dist/module/entity/infoPanel/index.js +76 -23
- package/dist/module/entity/infoPanel/index.js.map +1 -1
- package/dist/module/entity/light/pointLight/index.js +84 -48
- package/dist/module/entity/light/pointLight/index.js.map +1 -1
- package/dist/module/entity/mark/index.js +101 -51
- package/dist/module/entity/mark/index.js.map +1 -1
- package/dist/module/entity/model/index.js +151 -108
- package/dist/module/entity/model/index.js.map +1 -1
- package/dist/module/entity/model/load/loadFbx.js +8 -8
- package/dist/module/entity/model/load/loadFbx.js.map +1 -1
- package/dist/module/entity/model/load/loadGlb.js +11 -13
- package/dist/module/entity/model/load/loadGlb.js.map +1 -1
- package/dist/module/entity/model/load.js +57 -19
- package/dist/module/entity/model/load.js.map +1 -1
- package/dist/module/entity/poi/index.js +90 -34
- package/dist/module/entity/poi/index.js.map +1 -1
- package/dist/module/entity/shape/index.js +136 -67
- package/dist/module/entity/shape/index.js.map +1 -1
- package/dist/module/entity/spline/index.js +75 -22
- package/dist/module/entity/spline/index.js.map +1 -1
- package/dist/module/entity/strategy.js +274 -92
- package/dist/module/entity/strategy.js.map +1 -1
- package/dist/module/entity/traffic/realismTraffic/index.js +88 -59
- package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
- package/dist/module/entity/traffic/streamerTraffic/index.js +81 -50
- package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
- package/dist/module/entity/utils.js +13 -11
- package/dist/module/entity/utils.js.map +1 -1
- package/dist/module/entity/videoPanel/index.js +76 -23
- package/dist/module/entity/videoPanel/index.js.map +1 -1
- package/dist/module/environment/index.js +73 -54
- package/dist/module/environment/index.js.map +1 -1
- package/dist/module/environment/season/index.js +184 -342
- package/dist/module/environment/season/index.js.map +1 -1
- package/dist/module/eventBus/entityEvents.js +1 -1
- package/dist/module/eventBus/entityEvents.js.map +1 -1
- package/dist/module/eventBus/index.js +93 -79
- package/dist/module/eventBus/index.js.map +1 -1
- package/dist/module/material/index.js +334 -279
- package/dist/module/material/index.js.map +1 -1
- package/dist/module/scene/fileParse.js +369 -276
- package/dist/module/scene/fileParse.js.map +1 -1
- package/dist/module/scene/index.js +161 -106
- package/dist/module/scene/index.js.map +1 -1
- package/dist/module/tool/index.js +33 -26
- package/dist/module/tool/index.js.map +1 -1
- package/dist/sdkEntry.js +23 -2
- package/dist/sdkEntry.js.map +1 -1
- package/dist/utils/abstract.js +15 -12
- package/dist/utils/abstract.js.map +1 -1
- package/dist/utils/index.js +24 -23
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messageFn.js +18 -17
- package/dist/utils/messageFn.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
8
|
import { DoubleSide, MeshPhysicalMaterial, RepeatWrapping, SRGBColorSpace, TextureLoader, use } from '@anov/3d-core';
|
|
5
9
|
var SeasonEnum = /*#__PURE__*/function (SeasonEnum) {
|
|
6
10
|
SeasonEnum["Spring"] = "Spring";
|
|
@@ -9,7 +13,7 @@ var SeasonEnum = /*#__PURE__*/function (SeasonEnum) {
|
|
|
9
13
|
SeasonEnum["Winter"] = "Winter";
|
|
10
14
|
return SeasonEnum;
|
|
11
15
|
}(SeasonEnum || {}); // 冬
|
|
12
|
-
|
|
16
|
+
var PresetValue = {
|
|
13
17
|
Spring: {
|
|
14
18
|
treeSize: 1.0,
|
|
15
19
|
landSnowSize: 0.0,
|
|
@@ -51,8 +55,9 @@ const PresetValue = {
|
|
|
51
55
|
changeColor: [0.996, 0.960, 0.764]
|
|
52
56
|
}
|
|
53
57
|
};
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
var Season = /*#__PURE__*/function () {
|
|
59
|
+
function Season(app) {
|
|
60
|
+
_classCallCheck(this, Season);
|
|
56
61
|
_defineProperty(this, "app", void 0);
|
|
57
62
|
_defineProperty(this, "textureLeaf", void 0);
|
|
58
63
|
_defineProperty(this, "textureBole", void 0);
|
|
@@ -67,349 +72,186 @@ class Season {
|
|
|
67
72
|
this.app = app;
|
|
68
73
|
this.init();
|
|
69
74
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
_createClass(Season, [{
|
|
76
|
+
key: "init",
|
|
77
|
+
value: function init() {
|
|
78
|
+
var path = this.app.caseInstance.usePath;
|
|
79
|
+
var textureLoader = new TextureLoader();
|
|
80
|
+
this.textureLeaf = textureLoader.load("".concat(path, "season/Image_tree2.png"));
|
|
81
|
+
this.textureLeaf.colorSpace = SRGBColorSpace;
|
|
82
|
+
this.textureNoise = textureLoader.load("".concat(path, "season/T_TileNoise.png"));
|
|
83
|
+
this.textureNoise.colorSpace = SRGBColorSpace;
|
|
84
|
+
this.textureBole = textureLoader.load("".concat(path, "season/Image_tree3.png"));
|
|
85
|
+
this.textureBole.colorSpace = SRGBColorSpace;
|
|
86
|
+
this.uniforms = {
|
|
87
|
+
time: {
|
|
88
|
+
value: 1.0
|
|
89
|
+
},
|
|
90
|
+
treeSize: {
|
|
91
|
+
value: 0.3
|
|
92
|
+
},
|
|
93
|
+
noGran: {
|
|
94
|
+
value: 0.9
|
|
95
|
+
},
|
|
96
|
+
landSnowSize: {
|
|
97
|
+
value: 0.0
|
|
98
|
+
},
|
|
99
|
+
treeColor1: {
|
|
100
|
+
value: [0.0, 0.58, 0.0]
|
|
101
|
+
},
|
|
102
|
+
targetColor: {
|
|
103
|
+
value: [0.0, 0.58, 0.0]
|
|
104
|
+
},
|
|
105
|
+
changeColor: {
|
|
106
|
+
value: [0.5, 0.58, 0.5]
|
|
107
|
+
},
|
|
108
|
+
texture1: {
|
|
109
|
+
value: this.textureLeaf
|
|
110
|
+
},
|
|
111
|
+
texture2: {
|
|
112
|
+
value: this.textureNoise
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.uniforms.texture1.value.wrapS = this.uniforms.texture1.value.wrapT = RepeatWrapping;
|
|
116
|
+
this.uniforms.texture2.value.wrapS = this.uniforms.texture2.value.wrapT = RepeatWrapping;
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "setSeason",
|
|
120
|
+
value: function setSeason(type) {
|
|
121
|
+
var _this = this;
|
|
122
|
+
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2.0;
|
|
123
|
+
if (!this.haveSetMaterial) {
|
|
124
|
+
this.haveSetMaterial = true;
|
|
125
|
+
this.setLeafMaterial();
|
|
126
|
+
this.setLandMaterial();
|
|
127
|
+
this.setMassifMaterial();
|
|
128
|
+
use.useframe(function () {
|
|
129
|
+
_this.uniforms.time.value += 0.2;
|
|
130
|
+
});
|
|
106
131
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.uniforms.texture2.value.wrapS = this.uniforms.texture2.value.wrapT = RepeatWrapping;
|
|
110
|
-
}
|
|
111
|
-
setSeason(type, duration = 2.0) {
|
|
112
|
-
if (!this.haveSetMaterial) {
|
|
113
|
-
this.haveSetMaterial = true;
|
|
114
|
-
this.setLeafMaterial();
|
|
115
|
-
this.setLandMaterial();
|
|
116
|
-
this.setMassifMaterial();
|
|
117
|
-
use.useframe(() => {
|
|
118
|
-
this.uniforms.time.value += 0.2;
|
|
132
|
+
PresetValue[type] && Object.keys(PresetValue[type]).forEach(function (key) {
|
|
133
|
+
_this.uniforms[key].value = PresetValue[type][key];
|
|
119
134
|
});
|
|
120
135
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
vec2 u = f * f * ( 3.0 - 2.0 * f );
|
|
151
|
-
|
|
152
|
-
return mix( mix( hash( i + vec2( 0.0, 0.0 ) ),
|
|
153
|
-
hash( i + vec2( 1.0, 0.0 ) ), u.x),
|
|
154
|
-
mix( hash( i + vec2( 0.0, 1.0 ) ),
|
|
155
|
-
hash( i + vec2( 1.0, 1.0 ) ), u.x), u.y);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
${shader.vertexShader}`;
|
|
159
|
-
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', `#include <begin_vertex>
|
|
160
|
-
vUv = uv;
|
|
161
|
-
vNormal = normalize(normal);
|
|
162
|
-
vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
163
|
-
|
|
164
|
-
vec3 wind = vec3(
|
|
165
|
-
noise(position.xy * 0.5 + time * 0.1),
|
|
166
|
-
noise(position.yz * 0.5 + time * 0.1),
|
|
167
|
-
noise(position.zx * 0.5 + time * 0.1)
|
|
168
|
-
);
|
|
169
|
-
float strength = 0.5; // Adjust the strength of the wind effect
|
|
170
|
-
vec3 displacedPosition = position + wind * strength;
|
|
171
|
-
transformed = displacedPosition;
|
|
172
|
-
`);
|
|
173
|
-
shader.fragmentShader = `
|
|
174
|
-
uniform sampler2D texture1;
|
|
175
|
-
uniform sampler2D texture2;
|
|
176
|
-
uniform float treeSize;
|
|
177
|
-
uniform vec3 treeColor1;
|
|
178
|
-
uniform float landSnowSize;
|
|
179
|
-
varying vec3 vWorldPosition;
|
|
180
|
-
varying vec2 vUv;
|
|
181
|
-
|
|
182
|
-
vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){
|
|
183
|
-
vec2 xy = vec2(Position.x,Position.y);
|
|
184
|
-
vec2 xz = vec2(Position.x,Position.z);
|
|
185
|
-
vec2 yz = vec2(Position.y,Position.z);
|
|
186
|
-
float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);
|
|
187
|
-
float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);
|
|
188
|
-
return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);
|
|
189
|
-
}
|
|
190
|
-
${shader.fragmentShader}
|
|
191
|
-
`;
|
|
192
|
-
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', `
|
|
193
|
-
#include <map_fragment>
|
|
194
|
-
vec4 T1 = texture2D(texture1, vUv)*vec4(treeColor1,1.);
|
|
195
|
-
vec4 nT = texture2D(texture2, vUv);
|
|
196
|
-
|
|
197
|
-
vec4 noiseT=T3dPoi(texture2,vWorldPosition,vNormal,0.02);
|
|
198
|
-
|
|
199
|
-
diffuseColor = mix(diffuseColor, T1,pow(nT.r,treeSize) ); // 叠加效果,调整混合方式
|
|
200
|
-
float Si= clamp(pow(noiseT.r,(10.-landSnowSize))*landSnowSize*0.1,0.,1.);
|
|
201
|
-
diffuseColor = mix(diffuseColor,vec4(1.,1.,1.,diffuseColor.a), Si);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// diffuseColor =vec4(Si,Si,Si,1.) ;
|
|
205
|
-
|
|
206
|
-
`);
|
|
207
|
-
shader.uniforms.time = this.uniforms.time;
|
|
208
|
-
shader.uniforms.texture1 = {
|
|
209
|
-
value: this.textureLeaf
|
|
210
|
-
};
|
|
211
|
-
shader.uniforms.texture2 = {
|
|
212
|
-
value: this.textureNoise
|
|
213
|
-
};
|
|
214
|
-
shader.uniforms.treeSize = this.uniforms.treeSize;
|
|
215
|
-
shader.uniforms.treeColor1 = this.uniforms.treeColor1;
|
|
216
|
-
shader.uniforms.landSnowSize = this.uniforms.landSnowSize;
|
|
136
|
+
}, {
|
|
137
|
+
key: "setLeafMaterial",
|
|
138
|
+
value: function setLeafMaterial() {
|
|
139
|
+
var _this2 = this;
|
|
140
|
+
this.leafMaterial = new MeshPhysicalMaterial({
|
|
141
|
+
map: this.textureBole,
|
|
142
|
+
alphaTest: 0.2,
|
|
143
|
+
roughness: 1,
|
|
144
|
+
metalness: 0,
|
|
145
|
+
emissive: 0,
|
|
146
|
+
side: DoubleSide,
|
|
147
|
+
transparent: true,
|
|
148
|
+
depthWrite: true
|
|
149
|
+
});
|
|
150
|
+
this.leafMaterial.onBeforeCompile = function (shader, renderer) {
|
|
151
|
+
shader.vertexShader = "\n \n uniform float time;\n varying vec3 vWorldPosition;\n varying vec2 vUv;\n \n float hash( vec2 p ) {\n return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );\n }\n \n float noise( vec2 p ) {\n vec2 i = floor( p );\n vec2 f = fract( p );\n vec2 u = f * f * ( 3.0 - 2.0 * f );\n \n return mix( mix( hash( i + vec2( 0.0, 0.0 ) ), \n hash( i + vec2( 1.0, 0.0 ) ), u.x),\n mix( hash( i + vec2( 0.0, 1.0 ) ), \n hash( i + vec2( 1.0, 1.0 ) ), u.x), u.y);\n }\n \n ".concat(shader.vertexShader);
|
|
152
|
+
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', "#include <begin_vertex>\n vUv = uv;\n vNormal = normalize(normal);\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n \n vec3 wind = vec3(\n noise(position.xy * 0.5 + time * 0.1),\n noise(position.yz * 0.5 + time * 0.1),\n noise(position.zx * 0.5 + time * 0.1)\n );\n float strength = 0.5; // Adjust the strength of the wind effect\n vec3 displacedPosition = position + wind * strength;\n transformed = displacedPosition;\n ");
|
|
153
|
+
shader.fragmentShader = "\n uniform sampler2D texture1;\n uniform sampler2D texture2;\n uniform float treeSize;\n uniform vec3 treeColor1;\n uniform float landSnowSize;\n varying vec3 vWorldPosition;\n varying vec2 vUv;\n \n vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){\n vec2 xy = vec2(Position.x,Position.y);\n vec2 xz = vec2(Position.x,Position.z);\n vec2 yz = vec2(Position.y,Position.z);\n float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);\n float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);\n return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);\n }\n ".concat(shader.fragmentShader, "\n ");
|
|
154
|
+
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', " \n #include <map_fragment> \n vec4 T1 = texture2D(texture1, vUv)*vec4(treeColor1,1.);\n vec4 nT = texture2D(texture2, vUv);\n \n vec4 noiseT=T3dPoi(texture2,vWorldPosition,vNormal,0.02);\n \n diffuseColor = mix(diffuseColor, T1,pow(nT.r,treeSize) ); // \u53E0\u52A0\u6548\u679C\uFF0C\u8C03\u6574\u6DF7\u5408\u65B9\u5F0F\n float Si= clamp(pow(noiseT.r,(10.-landSnowSize))*landSnowSize*0.1,0.,1.);\n diffuseColor = mix(diffuseColor,vec4(1.,1.,1.,diffuseColor.a), Si);\n \n \n // diffuseColor =vec4(Si,Si,Si,1.) ;\n \n ");
|
|
155
|
+
shader.uniforms.time = _this2.uniforms.time;
|
|
156
|
+
shader.uniforms.texture1 = {
|
|
157
|
+
value: _this2.textureLeaf
|
|
158
|
+
};
|
|
159
|
+
shader.uniforms.texture2 = {
|
|
160
|
+
value: _this2.textureNoise
|
|
161
|
+
};
|
|
162
|
+
shader.uniforms.treeSize = _this2.uniforms.treeSize;
|
|
163
|
+
shader.uniforms.treeColor1 = _this2.uniforms.treeColor1;
|
|
164
|
+
shader.uniforms.landSnowSize = _this2.uniforms.landSnowSize;
|
|
217
165
|
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
this.app.caseInstance.treesMesh.forEach(object => {
|
|
221
|
-
object.material = this.leafMaterial;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
setLandMaterial() {
|
|
225
|
-
this.landMaterial = new MeshPhysicalMaterial({
|
|
226
|
-
// alphaTest: 0.2,
|
|
227
|
-
roughness: 1,
|
|
228
|
-
metalness: 0,
|
|
229
|
-
emissive: 0,
|
|
230
|
-
envMapIntensity: 0.2,
|
|
231
|
-
side: DoubleSide,
|
|
232
|
-
// transparent: true,
|
|
233
|
-
depthWrite: false
|
|
234
|
-
});
|
|
235
|
-
this.landMaterial.onBeforeCompile = (shader, renderer) => {
|
|
236
|
-
shader.vertexShader = `
|
|
237
|
-
varying vec3 vWorldPosition;
|
|
238
|
-
varying vec2 vUv;
|
|
239
|
-
${shader.vertexShader}`;
|
|
240
|
-
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', `#include <begin_vertex>
|
|
241
|
-
vUv = uv;
|
|
242
|
-
vNormal = normalize(normal);
|
|
243
|
-
vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
244
|
-
`);
|
|
245
|
-
shader.fragmentShader = `
|
|
246
|
-
uniform sampler2D texture1;
|
|
247
|
-
uniform sampler2D texture2;
|
|
248
|
-
uniform float treeSize;
|
|
249
|
-
uniform float noGran;
|
|
250
|
-
uniform vec3 treeColor1;
|
|
251
|
-
uniform vec3 targetColor;
|
|
252
|
-
uniform vec3 changeColor;
|
|
253
|
-
uniform float landSnowSize;
|
|
254
|
-
varying vec3 vWorldPosition;
|
|
255
|
-
varying vec2 vUv;
|
|
256
|
-
//varying vec2 vUv;
|
|
257
|
-
vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){
|
|
258
|
-
vec2 xy = vec2(Position.x,Position.y);
|
|
259
|
-
vec2 xz = vec2(Position.x,Position.z);
|
|
260
|
-
vec2 yz = vec2(Position.y,Position.z);
|
|
261
|
-
float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);
|
|
262
|
-
float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);
|
|
263
|
-
return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
${shader.fragmentShader}
|
|
267
|
-
`;
|
|
268
|
-
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', `
|
|
269
|
-
#include <map_fragment>
|
|
270
|
-
vec4 T1 = texture2D(texture1, vUv);
|
|
271
|
-
|
|
272
|
-
float d = distance(T1.rgb, targetColor);
|
|
273
|
-
float factor = smoothstep(0.4, 0.6, d);
|
|
274
|
-
// T1.rgb = mix(treeColor1, T1.rgb, factor);
|
|
275
|
-
|
|
276
|
-
float gray = dot(T1.rgb, vec3(0.299, 0.587, 0.114));
|
|
277
|
-
vec4 T1_gray =vec4(vec3(gray)*changeColor,1.);
|
|
278
|
-
|
|
279
|
-
T1.rgb = mix(T1_gray.rgb, T1.rgb, factor);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
vec4 nT = texture2D(texture2, vUv);
|
|
283
|
-
|
|
284
|
-
vec4 noiseT2d=pow(texture2D(texture2, vWorldPosition.xz*0.002),vec4(10.-landSnowSize));
|
|
285
|
-
|
|
286
|
-
diffuseColor = mix(diffuseColor, T1,pow(nT.r,treeSize) ); // 叠加效果,调整混合方式
|
|
287
|
-
diffuseColor=T1;
|
|
288
|
-
|
|
289
|
-
vec3 upDirection = vec3(0.0, 1.0, 0.0);
|
|
290
|
-
float dotProduct = dot(vNormal, upDirection);
|
|
291
|
-
float snowAmount = smoothstep(0.5, 1.0, dotProduct);
|
|
292
|
-
diffuseColor = mix(diffuseColor, vec4(1.0, 1., 1.,1.), snowAmount*landSnowSize*noiseT2d*0.1);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
`);
|
|
296
|
-
shader.uniforms.time = this.uniforms.time;
|
|
297
|
-
// shader.uniforms.texture1 = { value: matLandT0 };
|
|
298
|
-
shader.uniforms.texture1 = {
|
|
299
|
-
value: this.textureLand
|
|
300
|
-
};
|
|
301
|
-
shader.uniforms.texture2 = {
|
|
302
|
-
value: this.textureNoise
|
|
166
|
+
// material.userData.shader = shader;
|
|
303
167
|
};
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
uniform sampler2D texture2;
|
|
342
|
-
uniform float treeSize;
|
|
343
|
-
uniform float noGran;
|
|
344
|
-
uniform vec3 treeColor1;
|
|
345
|
-
uniform vec3 targetColor;
|
|
346
|
-
uniform vec3 changeColor;
|
|
347
|
-
uniform float landSnowSize;
|
|
348
|
-
varying vec3 vWorldPosition;
|
|
349
|
-
varying vec2 vUv;
|
|
350
|
-
|
|
351
|
-
vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){
|
|
352
|
-
vec2 xy = vec2(Position.x,Position.y);
|
|
353
|
-
vec2 xz = vec2(Position.x,Position.z);
|
|
354
|
-
vec2 yz = vec2(Position.y,Position.z);
|
|
355
|
-
float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);
|
|
356
|
-
float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);
|
|
357
|
-
return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
${shader.fragmentShader}
|
|
361
|
-
`;
|
|
362
|
-
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', `
|
|
363
|
-
#include <map_fragment>
|
|
364
|
-
vec4 T1 = texture2D(texture1, vUv);
|
|
365
|
-
|
|
366
|
-
float d = distance(T1.rgb, targetColor);
|
|
367
|
-
float factor = smoothstep(0.4, 0.6, d);
|
|
368
|
-
// T1.rgb = mix(treeColor1, T1.rgb, factor);
|
|
369
|
-
|
|
370
|
-
float gray = dot(T1.rgb, vec3(0.299, 0.587, 0.114));
|
|
371
|
-
vec4 T1_gray =vec4(vec3(gray)*changeColor,1.);
|
|
372
|
-
|
|
373
|
-
T1.rgb = mix(T1_gray.rgb, T1.rgb, factor);
|
|
374
|
-
|
|
375
|
-
diffuseColor=T1;
|
|
376
|
-
vec4 nT = texture2D(texture2, vUv);
|
|
377
|
-
|
|
378
|
-
float noiseT=pow( clamp(texture2D(texture2, vWorldPosition.xz*0.002).r,0.,1.),(10.0-landSnowSize));
|
|
379
|
-
vec4 noiseT2d=pow(texture2D(texture2, vWorldPosition.xz*0.002),vec4(10.0-landSnowSize));
|
|
380
|
-
|
|
381
|
-
//diffuseColor = mix(diffuseColor, T1,pow(nT.r,1.) ); // 叠加效果,调整混合方式
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
vec3 upDirection = vec3(0.0, 1.0, 0.0);
|
|
385
|
-
float dotProduct = dot(vNormal, upDirection);
|
|
386
|
-
float snowAmount = smoothstep(0.5, 1.0, dotProduct);
|
|
387
|
-
diffuseColor = mix(diffuseColor, vec4(5.0, 5., 5.,5.),snowAmount* noiseT*0.5*landSnowSize);
|
|
388
|
-
//diffuseColor=nT;
|
|
389
|
-
|
|
390
|
-
`);
|
|
391
|
-
shader.uniforms.time = this.uniforms.time;
|
|
392
|
-
// shader.uniforms.texture1 = { value: matLandT0 };
|
|
393
|
-
shader.uniforms.texture1 = {
|
|
394
|
-
value: this.textureMassif
|
|
395
|
-
};
|
|
396
|
-
shader.uniforms.texture2 = {
|
|
397
|
-
value: this.textureNoise
|
|
168
|
+
this.app.caseInstance.treesMesh.forEach(function (object) {
|
|
169
|
+
object.material = _this2.leafMaterial;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "setLandMaterial",
|
|
174
|
+
value: function setLandMaterial() {
|
|
175
|
+
var _this3 = this;
|
|
176
|
+
this.landMaterial = new MeshPhysicalMaterial({
|
|
177
|
+
// alphaTest: 0.2,
|
|
178
|
+
roughness: 1,
|
|
179
|
+
metalness: 0,
|
|
180
|
+
emissive: 0,
|
|
181
|
+
envMapIntensity: 0.2,
|
|
182
|
+
side: DoubleSide,
|
|
183
|
+
// transparent: true,
|
|
184
|
+
depthWrite: false
|
|
185
|
+
});
|
|
186
|
+
this.landMaterial.onBeforeCompile = function (shader, renderer) {
|
|
187
|
+
shader.vertexShader = " \n varying vec3 vWorldPosition;\n varying vec2 vUv;\n ".concat(shader.vertexShader);
|
|
188
|
+
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', "#include <begin_vertex>\n vUv = uv;\n vNormal = normalize(normal);\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n ");
|
|
189
|
+
shader.fragmentShader = "\n uniform sampler2D texture1;\n uniform sampler2D texture2;\n uniform float treeSize;\n uniform float noGran;\n uniform vec3 treeColor1;\n uniform vec3 targetColor;\n uniform vec3 changeColor;\n uniform float landSnowSize;\n varying vec3 vWorldPosition;\n varying vec2 vUv;\n //varying vec2 vUv;\n vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){\n vec2 xy = vec2(Position.x,Position.y);\n vec2 xz = vec2(Position.x,Position.z);\n vec2 yz = vec2(Position.y,Position.z);\n float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);\n float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);\n return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);\n }\n \n ".concat(shader.fragmentShader, "\n ");
|
|
190
|
+
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', " \n #include <map_fragment> \n vec4 T1 = texture2D(texture1, vUv);\n \n float d = distance(T1.rgb, targetColor);\n float factor = smoothstep(0.4, 0.6, d);\n // T1.rgb = mix(treeColor1, T1.rgb, factor);\n \n float gray = dot(T1.rgb, vec3(0.299, 0.587, 0.114));\n vec4 T1_gray =vec4(vec3(gray)*changeColor,1.);\n \n T1.rgb = mix(T1_gray.rgb, T1.rgb, factor);\n \n \n vec4 nT = texture2D(texture2, vUv);\n \n vec4 noiseT2d=pow(texture2D(texture2, vWorldPosition.xz*0.002),vec4(10.-landSnowSize));\n \n diffuseColor = mix(diffuseColor, T1,pow(nT.r,treeSize) ); // \u53E0\u52A0\u6548\u679C\uFF0C\u8C03\u6574\u6DF7\u5408\u65B9\u5F0F\n diffuseColor=T1;\n \n vec3 upDirection = vec3(0.0, 1.0, 0.0);\n float dotProduct = dot(vNormal, upDirection);\n float snowAmount = smoothstep(0.5, 1.0, dotProduct);\n diffuseColor = mix(diffuseColor, vec4(1.0, 1., 1.,1.), snowAmount*landSnowSize*noiseT2d*0.1);\n \n \n ");
|
|
191
|
+
shader.uniforms.time = _this3.uniforms.time;
|
|
192
|
+
// shader.uniforms.texture1 = { value: matLandT0 };
|
|
193
|
+
shader.uniforms.texture1 = {
|
|
194
|
+
value: _this3.textureLand
|
|
195
|
+
};
|
|
196
|
+
shader.uniforms.texture2 = {
|
|
197
|
+
value: _this3.textureNoise
|
|
198
|
+
};
|
|
199
|
+
shader.uniforms.treeSize = _this3.uniforms.treeSize;
|
|
200
|
+
shader.uniforms.noGran = _this3.uniforms.noGran;
|
|
201
|
+
shader.uniforms.treeColor1 = _this3.uniforms.treeColor1;
|
|
202
|
+
shader.uniforms.targetColor = _this3.uniforms.targetColor;
|
|
203
|
+
shader.uniforms.changeColor = _this3.uniforms.changeColor;
|
|
204
|
+
shader.uniforms.landSnowSize = _this3.uniforms.landSnowSize;
|
|
398
205
|
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
206
|
+
this.app.caseInstance.grasslandMesh.forEach(function (object) {
|
|
207
|
+
_this3.textureLand = object.material.map;
|
|
208
|
+
object.material = _this3.landMaterial;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "setMassifMaterial",
|
|
213
|
+
value: function setMassifMaterial() {
|
|
214
|
+
var _this4 = this;
|
|
215
|
+
this.massifMaterial = new MeshPhysicalMaterial({
|
|
216
|
+
alphaTest: 0.2,
|
|
217
|
+
roughness: 1,
|
|
218
|
+
metalness: 0,
|
|
219
|
+
emissive: 0,
|
|
220
|
+
envMapIntensity: 0.2,
|
|
221
|
+
side: DoubleSide,
|
|
222
|
+
transparent: true,
|
|
223
|
+
depthWrite: false
|
|
224
|
+
});
|
|
225
|
+
this.massifMaterial.onBeforeCompile = function (shader, renderer) {
|
|
226
|
+
// console.log(shader.vertexShader);
|
|
227
|
+
shader.vertexShader = " \n varying vec3 vWorldPosition;\n varying vec2 vUv;\n ".concat(shader.vertexShader);
|
|
228
|
+
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', "#include <begin_vertex>\n vUv = uv;\n \n vNormal = normalize(normal);\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n ");
|
|
229
|
+
shader.fragmentShader = "\n uniform sampler2D texture1;\n uniform sampler2D texture2;\n uniform float treeSize;\n uniform float noGran;\n uniform vec3 treeColor1;\n uniform vec3 targetColor;\n uniform vec3 changeColor;\n uniform float landSnowSize;\n varying vec3 vWorldPosition;\n varying vec2 vUv;\n \n vec4 T3dPoi (sampler2D T,vec3 Position,vec3 normal, float loop){\n vec2 xy = vec2(Position.x,Position.y);\n vec2 xz = vec2(Position.x,Position.z);\n vec2 yz = vec2(Position.y,Position.z);\n float ix =clamp((abs(normal.x)-0.4)*2.,0.,1.);\n float iy =clamp((abs(normal.y)-0.4)*2.,0.,1.);\n return mix((mix(texture2D( T, xy*loop),texture2D( T, yz*loop),ix)),texture2D( T, xz*loop),iy);\n }\n \n ".concat(shader.fragmentShader, "\n ");
|
|
230
|
+
shader.fragmentShader = shader.fragmentShader.replace('#include <map_fragment>', " \n #include <map_fragment> \n vec4 T1 = texture2D(texture1, vUv);\n \n float d = distance(T1.rgb, targetColor);\n float factor = smoothstep(0.4, 0.6, d);\n // T1.rgb = mix(treeColor1, T1.rgb, factor);\n \n float gray = dot(T1.rgb, vec3(0.299, 0.587, 0.114));\n vec4 T1_gray =vec4(vec3(gray)*changeColor,1.);\n \n T1.rgb = mix(T1_gray.rgb, T1.rgb, factor);\n \n diffuseColor=T1;\n vec4 nT = texture2D(texture2, vUv);\n \n float noiseT=pow( clamp(texture2D(texture2, vWorldPosition.xz*0.002).r,0.,1.),(10.0-landSnowSize));\n vec4 noiseT2d=pow(texture2D(texture2, vWorldPosition.xz*0.002),vec4(10.0-landSnowSize));\n \n //diffuseColor = mix(diffuseColor, T1,pow(nT.r,1.) ); // \u53E0\u52A0\u6548\u679C\uFF0C\u8C03\u6574\u6DF7\u5408\u65B9\u5F0F\n \n \n vec3 upDirection = vec3(0.0, 1.0, 0.0);\n float dotProduct = dot(vNormal, upDirection);\n float snowAmount = smoothstep(0.5, 1.0, dotProduct);\n diffuseColor = mix(diffuseColor, vec4(5.0, 5., 5.,5.),snowAmount* noiseT*0.5*landSnowSize);\n //diffuseColor=nT;\n \n ");
|
|
231
|
+
shader.uniforms.time = _this4.uniforms.time;
|
|
232
|
+
// shader.uniforms.texture1 = { value: matLandT0 };
|
|
233
|
+
shader.uniforms.texture1 = {
|
|
234
|
+
value: _this4.textureMassif
|
|
235
|
+
};
|
|
236
|
+
shader.uniforms.texture2 = {
|
|
237
|
+
value: _this4.textureNoise
|
|
238
|
+
};
|
|
239
|
+
shader.uniforms.treeSize = _this4.uniforms.treeSize;
|
|
240
|
+
shader.uniforms.noGran = _this4.uniforms.noGran;
|
|
241
|
+
shader.uniforms.treeColor1 = _this4.uniforms.treeColor1;
|
|
242
|
+
shader.uniforms.targetColor = _this4.uniforms.targetColor;
|
|
243
|
+
shader.uniforms.changeColor = _this4.uniforms.changeColor;
|
|
244
|
+
shader.uniforms.landSnowSize = _this4.uniforms.landSnowSize;
|
|
405
245
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
246
|
+
// material.userData.shader = shader;
|
|
247
|
+
};
|
|
248
|
+
this.app.caseInstance.massifMesh.forEach(function (object) {
|
|
249
|
+
_this4.textureMassif = object.material.map;
|
|
250
|
+
object.material = _this4.massifMaterial;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}]);
|
|
254
|
+
return Season;
|
|
255
|
+
}();
|
|
414
256
|
export default Season;
|
|
415
257
|
//# sourceMappingURL=index.js.map
|