@anov/3d 0.0.286 → 0.0.288
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 +40 -43
- package/dist/anov3d.js.map +1 -1
- package/dist/applicationApi.js +94 -118
- 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 +61 -113
- package/dist/module/animation/index.js.map +1 -1
- package/dist/module/animation/motion/index.js +58 -91
- package/dist/module/animation/motion/index.js.map +1 -1
- package/dist/module/animation/strategy.js +7 -21
- package/dist/module/animation/strategy.js.map +1 -1
- package/dist/module/camera/index.js +216 -278
- package/dist/module/camera/index.js.map +1 -1
- package/dist/module/develop/index.js +27 -35
- package/dist/module/develop/index.js.map +1 -1
- package/dist/module/entity/area/index.js +29 -87
- package/dist/module/entity/area/index.js.map +1 -1
- package/dist/module/entity/bar/index.js +5 -24
- package/dist/module/entity/bar/index.js.map +1 -1
- package/dist/module/entity/bar/style/bar_01.js +13 -52
- package/dist/module/entity/bar/style/bar_01.js.map +1 -1
- package/dist/module/entity/bar/style/index.js +7 -21
- package/dist/module/entity/bar/style/index.js.map +1 -1
- package/dist/module/entity/baseEntity.js +43 -66
- package/dist/module/entity/baseEntity.js.map +1 -1
- package/dist/module/entity/batch/index.js +77 -168
- package/dist/module/entity/batch/index.js.map +1 -1
- package/dist/module/entity/dispose.js +14 -16
- package/dist/module/entity/dispose.js.map +1 -1
- package/dist/module/entity/flyline/index.js +34 -90
- package/dist/module/entity/flyline/index.js.map +1 -1
- package/dist/module/entity/group/index.js +59 -75
- package/dist/module/entity/group/index.js.map +1 -1
- package/dist/module/entity/heatmap/index.js +62 -79
- package/dist/module/entity/heatmap/index.js.map +1 -1
- package/dist/module/entity/hybridList.js +49 -67
- package/dist/module/entity/hybridList.js.map +1 -1
- package/dist/module/entity/index.js +442 -644
- package/dist/module/entity/index.js.map +1 -1
- package/dist/module/entity/infoPanel/index.js +23 -76
- package/dist/module/entity/infoPanel/index.js.map +1 -1
- package/dist/module/entity/light/pointLight/index.js +48 -84
- package/dist/module/entity/light/pointLight/index.js.map +1 -1
- package/dist/module/entity/mark/index.js +51 -101
- package/dist/module/entity/mark/index.js.map +1 -1
- package/dist/module/entity/model/index.js +108 -151
- 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 +13 -11
- package/dist/module/entity/model/load/loadGlb.js.map +1 -1
- package/dist/module/entity/model/load.js +19 -57
- package/dist/module/entity/model/load.js.map +1 -1
- package/dist/module/entity/poi/index.js +34 -90
- package/dist/module/entity/poi/index.js.map +1 -1
- package/dist/module/entity/shape/index.js +67 -136
- package/dist/module/entity/shape/index.js.map +1 -1
- package/dist/module/entity/spline/index.js +22 -75
- package/dist/module/entity/spline/index.js.map +1 -1
- package/dist/module/entity/strategy.js +92 -274
- package/dist/module/entity/strategy.js.map +1 -1
- package/dist/module/entity/traffic/realismTraffic/index.js +59 -88
- package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
- package/dist/module/entity/traffic/streamerTraffic/index.js +50 -81
- package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
- package/dist/module/entity/utils.js +11 -13
- package/dist/module/entity/utils.js.map +1 -1
- package/dist/module/entity/videoPanel/index.js +23 -76
- package/dist/module/entity/videoPanel/index.js.map +1 -1
- package/dist/module/environment/index.js +54 -73
- package/dist/module/environment/index.js.map +1 -1
- package/dist/module/environment/season/index.js +342 -184
- 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 +79 -93
- package/dist/module/eventBus/index.js.map +1 -1
- package/dist/module/material/index.js +279 -334
- package/dist/module/material/index.js.map +1 -1
- package/dist/module/scene/fileParse.js +277 -369
- package/dist/module/scene/fileParse.js.map +1 -1
- package/dist/module/scene/index.js +106 -161
- package/dist/module/scene/index.js.map +1 -1
- package/dist/module/tool/index.js +26 -33
- package/dist/module/tool/index.js.map +1 -1
- package/dist/sdkEntry.js +2 -23
- package/dist/sdkEntry.js.map +1 -1
- package/dist/utils/abstract.js +12 -15
- package/dist/utils/abstract.js.map +1 -1
- package/dist/utils/index.js +23 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messageFn.js +17 -18
- package/dist/utils/messageFn.js.map +1 -1
- package/package.json +6 -3
|
@@ -1,10 +1,6 @@
|
|
|
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; }
|
|
5
1
|
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; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
3
|
+
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); }
|
|
8
4
|
import { DoubleSide, MeshPhysicalMaterial, RepeatWrapping, SRGBColorSpace, TextureLoader, use } from '@anov/3d-core';
|
|
9
5
|
var SeasonEnum = /*#__PURE__*/function (SeasonEnum) {
|
|
10
6
|
SeasonEnum["Spring"] = "Spring";
|
|
@@ -13,7 +9,7 @@ var SeasonEnum = /*#__PURE__*/function (SeasonEnum) {
|
|
|
13
9
|
SeasonEnum["Winter"] = "Winter";
|
|
14
10
|
return SeasonEnum;
|
|
15
11
|
}(SeasonEnum || {}); // 冬
|
|
16
|
-
|
|
12
|
+
const PresetValue = {
|
|
17
13
|
Spring: {
|
|
18
14
|
treeSize: 1.0,
|
|
19
15
|
landSnowSize: 0.0,
|
|
@@ -55,9 +51,8 @@ var PresetValue = {
|
|
|
55
51
|
changeColor: [0.996, 0.960, 0.764]
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_classCallCheck(this, Season);
|
|
54
|
+
class Season {
|
|
55
|
+
constructor(app) {
|
|
61
56
|
_defineProperty(this, "app", void 0);
|
|
62
57
|
_defineProperty(this, "textureLeaf", void 0);
|
|
63
58
|
_defineProperty(this, "textureBole", void 0);
|
|
@@ -72,186 +67,349 @@ var Season = /*#__PURE__*/function () {
|
|
|
72
67
|
this.app = app;
|
|
73
68
|
this.init();
|
|
74
69
|
}
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
});
|
|
70
|
+
init() {
|
|
71
|
+
const path = this.app.caseInstance.usePath;
|
|
72
|
+
const textureLoader = new TextureLoader();
|
|
73
|
+
this.textureLeaf = textureLoader.load(`${path}season/Image_tree2.png`);
|
|
74
|
+
this.textureLeaf.colorSpace = SRGBColorSpace;
|
|
75
|
+
this.textureNoise = textureLoader.load(`${path}season/T_TileNoise.png`);
|
|
76
|
+
this.textureNoise.colorSpace = SRGBColorSpace;
|
|
77
|
+
this.textureBole = textureLoader.load(`${path}season/Image_tree3.png`);
|
|
78
|
+
this.textureBole.colorSpace = SRGBColorSpace;
|
|
79
|
+
this.uniforms = {
|
|
80
|
+
time: {
|
|
81
|
+
value: 1.0
|
|
82
|
+
},
|
|
83
|
+
treeSize: {
|
|
84
|
+
value: 0.3
|
|
85
|
+
},
|
|
86
|
+
noGran: {
|
|
87
|
+
value: 0.9
|
|
88
|
+
},
|
|
89
|
+
landSnowSize: {
|
|
90
|
+
value: 0.0
|
|
91
|
+
},
|
|
92
|
+
treeColor1: {
|
|
93
|
+
value: [0.0, 0.58, 0.0]
|
|
94
|
+
},
|
|
95
|
+
targetColor: {
|
|
96
|
+
value: [0.0, 0.58, 0.0]
|
|
97
|
+
},
|
|
98
|
+
changeColor: {
|
|
99
|
+
value: [0.5, 0.58, 0.5]
|
|
100
|
+
},
|
|
101
|
+
texture1: {
|
|
102
|
+
value: this.textureLeaf
|
|
103
|
+
},
|
|
104
|
+
texture2: {
|
|
105
|
+
value: this.textureNoise
|
|
131
106
|
}
|
|
132
|
-
|
|
133
|
-
|
|
107
|
+
};
|
|
108
|
+
this.uniforms.texture1.value.wrapS = this.uniforms.texture1.value.wrapT = RepeatWrapping;
|
|
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;
|
|
134
119
|
});
|
|
135
120
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
121
|
+
PresetValue[type] && Object.keys(PresetValue[type]).forEach(key => {
|
|
122
|
+
this.uniforms[key].value = PresetValue[type][key];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
setLeafMaterial() {
|
|
126
|
+
this.leafMaterial = new MeshPhysicalMaterial({
|
|
127
|
+
map: this.textureBole,
|
|
128
|
+
alphaTest: 0.2,
|
|
129
|
+
roughness: 1,
|
|
130
|
+
metalness: 0,
|
|
131
|
+
emissive: 0,
|
|
132
|
+
side: DoubleSide,
|
|
133
|
+
transparent: true,
|
|
134
|
+
depthWrite: true
|
|
135
|
+
});
|
|
136
|
+
this.leafMaterial.onBeforeCompile = (shader, renderer) => {
|
|
137
|
+
shader.vertexShader = `
|
|
138
|
+
|
|
139
|
+
uniform float time;
|
|
140
|
+
varying vec3 vWorldPosition;
|
|
141
|
+
varying vec2 vUv;
|
|
142
|
+
|
|
143
|
+
float hash( vec2 p ) {
|
|
144
|
+
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
float noise( vec2 p ) {
|
|
148
|
+
vec2 i = floor( p );
|
|
149
|
+
vec2 f = fract( p );
|
|
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
|
|
167
210
|
};
|
|
168
|
-
|
|
169
|
-
|
|
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;
|
|
211
|
+
shader.uniforms.texture2 = {
|
|
212
|
+
value: this.textureNoise
|
|
205
213
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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;
|
|
214
|
+
shader.uniforms.treeSize = this.uniforms.treeSize;
|
|
215
|
+
shader.uniforms.treeColor1 = this.uniforms.treeColor1;
|
|
216
|
+
shader.uniforms.landSnowSize = this.uniforms.landSnowSize;
|
|
245
217
|
|
|
246
|
-
|
|
218
|
+
// material.userData.shader = shader;
|
|
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
|
|
247
300
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
301
|
+
shader.uniforms.texture2 = {
|
|
302
|
+
value: this.textureNoise
|
|
303
|
+
};
|
|
304
|
+
shader.uniforms.treeSize = this.uniforms.treeSize;
|
|
305
|
+
shader.uniforms.noGran = this.uniforms.noGran;
|
|
306
|
+
shader.uniforms.treeColor1 = this.uniforms.treeColor1;
|
|
307
|
+
shader.uniforms.targetColor = this.uniforms.targetColor;
|
|
308
|
+
shader.uniforms.changeColor = this.uniforms.changeColor;
|
|
309
|
+
shader.uniforms.landSnowSize = this.uniforms.landSnowSize;
|
|
310
|
+
};
|
|
311
|
+
this.app.caseInstance.grasslandMesh.forEach(object => {
|
|
312
|
+
this.textureLand = object.material.map;
|
|
313
|
+
object.material = this.landMaterial;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
setMassifMaterial() {
|
|
317
|
+
this.massifMaterial = new MeshPhysicalMaterial({
|
|
318
|
+
alphaTest: 0.2,
|
|
319
|
+
roughness: 1,
|
|
320
|
+
metalness: 0,
|
|
321
|
+
emissive: 0,
|
|
322
|
+
envMapIntensity: 0.2,
|
|
323
|
+
side: DoubleSide,
|
|
324
|
+
transparent: true,
|
|
325
|
+
depthWrite: false
|
|
326
|
+
});
|
|
327
|
+
this.massifMaterial.onBeforeCompile = (shader, renderer) => {
|
|
328
|
+
// console.log(shader.vertexShader);
|
|
329
|
+
shader.vertexShader = `
|
|
330
|
+
varying vec3 vWorldPosition;
|
|
331
|
+
varying vec2 vUv;
|
|
332
|
+
${shader.vertexShader}`;
|
|
333
|
+
shader.vertexShader = shader.vertexShader.replace('#include <begin_vertex>', `#include <begin_vertex>
|
|
334
|
+
vUv = uv;
|
|
335
|
+
|
|
336
|
+
vNormal = normalize(normal);
|
|
337
|
+
vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
338
|
+
`);
|
|
339
|
+
shader.fragmentShader = `
|
|
340
|
+
uniform sampler2D texture1;
|
|
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
|
|
398
|
+
};
|
|
399
|
+
shader.uniforms.treeSize = this.uniforms.treeSize;
|
|
400
|
+
shader.uniforms.noGran = this.uniforms.noGran;
|
|
401
|
+
shader.uniforms.treeColor1 = this.uniforms.treeColor1;
|
|
402
|
+
shader.uniforms.targetColor = this.uniforms.targetColor;
|
|
403
|
+
shader.uniforms.changeColor = this.uniforms.changeColor;
|
|
404
|
+
shader.uniforms.landSnowSize = this.uniforms.landSnowSize;
|
|
405
|
+
|
|
406
|
+
// material.userData.shader = shader;
|
|
407
|
+
};
|
|
408
|
+
this.app.caseInstance.massifMesh.forEach(object => {
|
|
409
|
+
this.textureMassif = object.material.map;
|
|
410
|
+
object.material = this.massifMaterial;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
256
414
|
export default Season;
|
|
257
415
|
//# sourceMappingURL=index.js.map
|