@anov/3d-ability 0.0.4-alpha8 → 0.0.4

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.
Files changed (37) hide show
  1. package/dist/camera/index.d.ts +4 -0
  2. package/dist/camera/index.js +44 -26
  3. package/dist/camera/index.js.map +1 -1
  4. package/dist/environment/sky/index.js +5 -2
  5. package/dist/environment/sky/index.js.map +1 -1
  6. package/dist/index.d.ts +3 -4
  7. package/dist/index.js +3 -4
  8. package/dist/index.js.map +1 -1
  9. package/dist/poi/core/Sprite.d.ts +1 -0
  10. package/dist/poi/core/Sprite.js +11 -0
  11. package/dist/poi/core/Sprite.js.map +1 -1
  12. package/dist/poi/utils/css.d.ts +4 -4
  13. package/dist/poi/utils/css.js +12 -8
  14. package/dist/poi/utils/css.js.map +1 -1
  15. package/dist/weather/fog2DMesh.d.ts +14 -0
  16. package/dist/weather/fog2DMesh.js +77 -0
  17. package/dist/weather/fog2DMesh.js.map +1 -0
  18. package/dist/weather/glsl/fog.d.ts +2 -0
  19. package/dist/weather/glsl/fog.js +3 -0
  20. package/dist/weather/glsl/fog.js.map +1 -0
  21. package/dist/weather/index.d.ts +4 -0
  22. package/dist/weather/index.js +12 -0
  23. package/dist/weather/index.js.map +1 -0
  24. package/package.json +3 -3
  25. package/dist/animation/index.d.ts +0 -0
  26. package/dist/animation/index.js +0 -2
  27. package/dist/animation/index.js.map +0 -1
  28. package/dist/core/mouseDrawe.d.ts +0 -2
  29. package/dist/core/mouseDrawe.js +0 -2
  30. package/dist/core/mouseDrawe.js.map +0 -1
  31. package/dist/environment/cloud/cloud.d.ts +0 -1
  32. package/dist/environment/cloud/cloud.js +0 -2
  33. package/dist/environment/cloud/cloud.js.map +0 -1
  34. package/dist/environment/cloud/index.d.ts +0 -7
  35. package/dist/environment/cloud/index.js +0 -61
  36. package/dist/environment/cloud/index.js.map +0 -1
  37. package/dist/poi/core/Css2D.d.ts +0 -20
@@ -5,6 +5,10 @@ declare class Camera {
5
5
  private controls;
6
6
  private isTransitionPeriod;
7
7
  constructor(camera: PerspectiveCamera, controls: OrbitControls);
8
+ /**
9
+ * handle camera changed
10
+ */
11
+ private handleChanged;
8
12
  /**
9
13
  * caclCurrentPos
10
14
  * @param currentPos
@@ -14,14 +14,32 @@ var Camera = /*#__PURE__*/function () {
14
14
  _defineProperty(this, "isTransitionPeriod", false);
15
15
  this.camera = camera;
16
16
  this.controls = controls;
17
+ this.controls.object = this.camera;
18
+ // this.handleChanged()
17
19
  }
18
20
 
19
21
  /**
20
- * caclCurrentPos
21
- * @param currentPos
22
- * @returns
23
- */
22
+ * handle camera changed
23
+ */
24
24
  _createClass(Camera, [{
25
+ key: "handleChanged",
26
+ value: function handleChanged() {
27
+ var _this = this;
28
+ this.controls.addEventListener('change', function () {
29
+ if (!_this.isTransitionPeriod) {
30
+ var lookat = _this.controls.target;
31
+ var position = _this.camera.position;
32
+ console.log('camera changed', lookat, position);
33
+ }
34
+ });
35
+ }
36
+
37
+ /**
38
+ * caclCurrentPos
39
+ * @param currentPos
40
+ * @returns
41
+ */
42
+ }, {
25
43
  key: "caclCurrentPos",
26
44
  value: function caclCurrentPos(currentPos, pitch) {
27
45
  var box = new Box3();
@@ -83,7 +101,7 @@ var Camera = /*#__PURE__*/function () {
83
101
  }, {
84
102
  key: "focus",
85
103
  value: function focus(params) {
86
- var _this = this;
104
+ var _this2 = this;
87
105
  return new Promise(function (res) {
88
106
  var position = params.target,
89
107
  pitch = params.pitch,
@@ -104,8 +122,8 @@ var Camera = /*#__PURE__*/function () {
104
122
  onComplate: function onComplate() {
105
123
  var _params$duration;
106
124
  res({
107
- position: _this.camera.position.toArray(),
108
- target: _this.controls.target.toArray(),
125
+ position: _this2.camera.position.toArray(),
126
+ target: _this2.controls.target.toArray(),
109
127
  isTrigger: true,
110
128
  duration: (_params$duration = params.duration) !== null && _params$duration !== void 0 ? _params$duration : 0,
111
129
  userInput: true,
@@ -116,15 +134,15 @@ var Camera = /*#__PURE__*/function () {
116
134
  };
117
135
  if (Array.isArray(position[0])) {
118
136
  var currentPos = position;
119
- var _this$caclCurrentPos = _this.caclCurrentPos(currentPos, 0),
120
- lastPosition = _this$caclCurrentPos.lastPosition,
121
- lastLookat = _this$caclCurrentPos.lastLookat;
122
- _this.moveCameraTo(lastPosition, lastLookat, pitch, moveOptions());
137
+ var _this2$caclCurrentPos = _this2.caclCurrentPos(currentPos, 0),
138
+ lastPosition = _this2$caclCurrentPos.lastPosition,
139
+ lastLookat = _this2$caclCurrentPos.lastLookat;
140
+ _this2.moveCameraTo(lastPosition, lastLookat, pitch, moveOptions());
123
141
  } else {
124
142
  var _currentPos = position;
125
- var _lastPosition = _this.caclSingleCoordinate(_this.controls.target, _this.camera.position, new Vector3().fromArray(_currentPos));
126
- var _lastLookat = _this.caclTargetByPitch(0, new Vector3().fromArray(_currentPos), _lastPosition);
127
- _this.moveCameraTo(_lastPosition, _lastLookat, pitch, moveOptions());
143
+ var _lastPosition = _this2.caclSingleCoordinate(_this2.controls.target, _this2.camera.position, new Vector3().fromArray(_currentPos));
144
+ var _lastLookat = _this2.caclTargetByPitch(0, new Vector3().fromArray(_currentPos), _lastPosition);
145
+ _this2.moveCameraTo(_lastPosition, _lastLookat, pitch, moveOptions());
128
146
  }
129
147
  });
130
148
  }
@@ -136,10 +154,10 @@ var Camera = /*#__PURE__*/function () {
136
154
  }, {
137
155
  key: "set",
138
156
  value: function set(params) {
139
- var _this2 = this;
157
+ var _this3 = this;
140
158
  return new Promise(function (res, _) {
141
159
  var _ref3;
142
- _this2.moveCameraTo(new Vector3(params.position[0], params.position[1], params.position[2]), new Vector3(params.target[0], params.target[1], params.target[2]), 0, {
160
+ _this3.moveCameraTo(new Vector3(params.position[0], params.position[1], params.position[2]), new Vector3(params.target[0], params.target[1], params.target[2]), 0, {
143
161
  duration: (_ref3 = params.duration && params.duration * 1000) !== null && _ref3 !== void 0 ? _ref3 : 1000,
144
162
  onUpdate: function onUpdate(_ref4) {
145
163
  var position = _ref4.position,
@@ -154,8 +172,8 @@ var Camera = /*#__PURE__*/function () {
154
172
  onComplate: function onComplate() {
155
173
  var _params$duration2;
156
174
  res({
157
- position: _this2.camera.position.toArray(),
158
- target: _this2.controls.target.toArray(),
175
+ position: _this3.camera.position.toArray(),
176
+ target: _this3.controls.target.toArray(),
159
177
  isTrigger: true,
160
178
  duration: (_params$duration2 = params.duration) !== null && _params$duration2 !== void 0 ? _params$duration2 : 0,
161
179
  userInput: true
@@ -187,7 +205,7 @@ var Camera = /*#__PURE__*/function () {
187
205
  }, {
188
206
  key: "moveCameraTo",
189
207
  value: function moveCameraTo(position, target) {
190
- var _this3 = this;
208
+ var _this4 = this;
191
209
  var pitch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
192
210
  var options = arguments.length > 3 ? arguments[3] : undefined;
193
211
  var currentPoition = this.camera.position.clone();
@@ -208,27 +226,27 @@ var Camera = /*#__PURE__*/function () {
208
226
  p: -this.camera.rotation.x + (pitch ? MathUtils.degToRad(-pitch) : 0)
209
227
  }, (options === null || options === void 0 ? void 0 : options.duration) || 1000).onStart(function () {
210
228
  (options === null || options === void 0 ? void 0 : options.onStart) && options.onStart();
211
- _this3.controls.enabled = false;
212
- _this3.isTransitionPeriod = true;
229
+ _this4.controls.enabled = false;
230
+ _this4.isTransitionPeriod = true;
213
231
  }).easing(TWEEN.Easing.Quadratic.InOut).onUpdate(function (_ref5) {
214
232
  var t = _ref5.t,
215
233
  lookat = _ref5.lookat,
216
234
  p = _ref5.p;
217
- _this3.controls.target.copy(lookat);
235
+ _this4.controls.target.copy(lookat);
218
236
  if (pitch)
219
237
  // @ts-ignore
220
- _this3.camera.rotationParent.x = p;
238
+ _this4.camera.rotationParent.x = p;
221
239
  var currentPosition = currentPositionInterpolation.lerpVectors(currentPoition, position, t);
222
- _this3.camera.position.copy(currentPosition);
240
+ _this4.camera.position.copy(currentPosition);
223
241
  (options === null || options === void 0 ? void 0 : options.onUpdate) && options.onUpdate({
224
242
  position: currentPosition,
225
243
  lookat: lookat
226
244
  });
227
245
  }).onComplete(function () {
228
246
  (options === null || options === void 0 ? void 0 : options.onComplate) && options.onComplate();
229
- _this3.controls.enabled = true;
247
+ _this4.controls.enabled = true;
230
248
  setTimeout(function () {
231
- _this3.isTransitionPeriod = false;
249
+ _this4.isTransitionPeriod = false;
232
250
  });
233
251
  }).start();
234
252
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Box3","MathUtils","TWEEN","Vector3","Camera","camera","controls","currentPos","pitch","box","setFromPoints","map","item","center","getCenter","size","getSize","halfDiagonal","length","maxDistance","Math","tan","fov","PI","cameraToCenterDistance","directionVector","position","clone","sub","target","normalize","lastPosition","multiplyScalar","add","lastLookat","caclTargetByPitch","subVectors","upVector","localPitchAxis","crossVectors","applyAxisAngle","degToRad","distance","distanceTo","newTarget","prevTarget","prevPosition","lastTarget","params","Promise","res","duration","moveOptions","onUpdate","lookat","onComplate","toArray","isTrigger","userInput","Array","isArray","caclCurrentPos","moveCameraTo","caclSingleCoordinate","fromArray","_","x","y","z","options","currentPoition","currentPositionInterpolation","copy","Tween","t","p","to","rotation","onStart","enabled","isTransitionPeriod","easing","Easing","Quadratic","InOut","rotationParent","currentPosition","lerpVectors","onComplete","setTimeout","start"],"sources":["../../src/camera/index.ts"],"sourcesContent":["import type { OrbitControls, PerspectiveCamera } from '@anov/3d-core'\nimport { Box3, MathUtils, TWEEN, Vector3 } from '@anov/3d-core'\n\ntype vector3Array = [number, number, number]\ninterface ChangeCameraPresetOptions {\n duration?: number\n onUpdate?: (params: { position: Vector3; lookat: Vector3 }) => void\n onStart?: () => void\n onComplate?: () => void\n}\n\nclass Camera {\n private camera: PerspectiveCamera\n private controls: OrbitControls\n private isTransitionPeriod = false\n\n constructor(camera: PerspectiveCamera, controls: OrbitControls) {\n this.camera = camera\n this.controls = controls\n }\n\n /**\n * caclCurrentPos\n * @param currentPos\n * @returns\n */\n private caclCurrentPos(currentPos: vector3Array[], pitch: number) {\n const box = new Box3()\n\n box.setFromPoints(currentPos.map(item => new Vector3(item[0], item[1], item[2])))\n\n const center = box.getCenter(new Vector3())\n const size = box.getSize(new Vector3())\n const halfDiagonal = size.length() * 0.5\n\n const maxDistance = halfDiagonal / Math.tan(this.camera.fov / 2 * Math.PI / 180)\n const cameraToCenterDistance = maxDistance\n const directionVector = (this.camera.position.clone()).sub(this.controls.target).normalize() // 相机指向物体中心的向量\n\n const lastPosition = directionVector.multiplyScalar(cameraToCenterDistance).add(center)\n const lastLookat = this.caclTargetByPitch(pitch, center, lastPosition)\n\n return {\n lastPosition,\n lastLookat,\n }\n }\n\n /**\n * caclTargetByPitch\n * @param pitch\n * @param target\n * @param position\n * @returns\n */\n private caclTargetByPitch(pitch: number, target: Vector3, position: Vector3) {\n const directionVector = new Vector3().subVectors(target, position)\n const upVector = new Vector3(0, 1, 0)\n const localPitchAxis = new Vector3().crossVectors(directionVector, upVector).normalize()\n\n directionVector.applyAxisAngle(localPitchAxis, MathUtils.degToRad(pitch))\n\n const distance = position.distanceTo(target)\n const newTarget = position.clone().add(directionVector.normalize().multiplyScalar(distance))\n\n return newTarget\n }\n\n /**\n * caclSingle Coordinate\n * @param prevTarget\n * @param prevPosition\n * @param lastTarget\n * @returns\n */\n private caclSingleCoordinate(prevTarget: Vector3, prevPosition: Vector3, lastTarget: Vector3) {\n const directionVector = lastTarget.clone().sub(prevTarget).normalize()\n return directionVector.multiplyScalar(lastTarget.distanceTo(prevTarget)).add(prevPosition)\n }\n\n /**\n * focus On Position\n * @param params\n */\n focus(params: { target: vector3Array | vector3Array[]; pitch?: number; duration?: number }) {\n return new Promise((res) => {\n const { target: position, pitch, duration } = params\n const moveOptions = () => ({\n duration: (duration && duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n // sendToMessage(MessageType.Event, 'onCameraChanged', EMessageStatus.Success, undefined, {\n // position: position.toArray(),\n // target: lookat.toArray(),\n // })\n },\n onComplate: () => {\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\n isTrigger: true,\n duration: params.duration ?? 0,\n userInput: true,\n pitch: pitch ?? 40,\n })\n },\n }) as ChangeCameraPresetOptions\n\n if (Array.isArray(position[0])) {\n const currentPos = position as vector3Array[]\n const { lastPosition, lastLookat } = this.caclCurrentPos(currentPos, 0)\n\n this.moveCameraTo(\n lastPosition,\n lastLookat,\n pitch,\n moveOptions(),\n )\n }\n else {\n const currentPos = position as vector3Array\n const lastPosition = this.caclSingleCoordinate(this.controls.target, this.camera.position, new Vector3().fromArray(currentPos))\n const lastLookat = this.caclTargetByPitch(0, new Vector3().fromArray(currentPos), lastPosition)\n\n this.moveCameraTo(\n lastPosition,\n lastLookat,\n pitch,\n moveOptions(),\n )\n }\n })\n }\n\n /**\n * set camera\n * @param params\n */\n set(params: { position: vector3Array; target: vector3Array; isTrigger?: boolean; duration?: number }) {\n return new Promise ((res, _) => {\n this.moveCameraTo(\n new Vector3(params.position[0], params.position[1], params.position[2]),\n new Vector3(params.target[0], params.target[1], params.target[2]),\n 0,\n {\n duration: (params.duration && params.duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n // params.isTrigger\n // && sendToMessage(MessageType.Event, 'onCameraChanged', EMessageStatus.Success, undefined, {\n // position: position.toArray(),\n // target: lookat.toArray(),\n // })\n },\n onComplate: () => {\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\n isTrigger: true,\n duration: params.duration ?? 0,\n userInput: true,\n })\n },\n })\n })\n }\n\n /**\n * get Camera info\n * @returns\n */\n get() {\n return {\n position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],\n target: [this.controls.target.x, this.controls.target.y, this.controls.target.z],\n }\n }\n\n /**\n * interpolation move camera\n * @param position\n * @param target\n * @param options\n */\n private moveCameraTo(position: Vector3, target: Vector3, pitch = 0, options?: ChangeCameraPresetOptions) {\n const currentPoition = this.camera.position.clone()\n const currentPositionInterpolation = new Vector3()\n\n if (options?.duration === 0) {\n this.camera.position.copy(position)\n this.controls.target.copy(target)\n\n options?.onComplate && options.onComplate()\n return\n }\n\n new TWEEN.Tween({ t: 0, lookat: this.controls.target.clone(), p: 0 }).to({ t: 1, lookat: target, p: (-this.camera.rotation.x + (pitch ? MathUtils.degToRad(-pitch) : 0)) }, options?.duration || 1000)\n .onStart(() => {\n options?.onStart && options.onStart()\n this.controls.enabled = false\n this.isTransitionPeriod = true\n })\n .easing(TWEEN.Easing.Quadratic.InOut)\n .onUpdate(({ t, lookat, p }) => {\n this.controls.target.copy(lookat)\n\n if (pitch)\n // @ts-ignore\n this.camera.rotationParent.x = p\n\n const currentPosition = currentPositionInterpolation.lerpVectors(currentPoition, position, t)\n this.camera.position.copy(currentPosition)\n options?.onUpdate && options.onUpdate({ position: currentPosition, lookat })\n })\n .onComplete(() => {\n options?.onComplate && options.onComplate()\n this.controls.enabled = true\n\n setTimeout(() => {\n this.isTransitionPeriod = false\n })\n })\n .start()\n }\n}\n\nexport default Camera"],"mappings":";;;;;;;AACA,SAASA,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,QAAQ,eAAe;AAAA,IAUzDC,MAAM;EAKV,gBAAYC,MAAyB,EAAEC,QAAuB,EAAE;IAAA;IAAA;IAAA;IAAA,4CAFnC,KAAK;IAGhC,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC1B;;EAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,wBAAuBC,UAA0B,EAAEC,KAAa,EAAE;MAChE,IAAMC,GAAG,GAAG,IAAIT,IAAI,EAAE;MAEtBS,GAAG,CAACC,aAAa,CAACH,UAAU,CAACI,GAAG,CAAC,UAAAC,IAAI;QAAA,OAAI,IAAIT,OAAO,CAACS,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,CAAC;MAAA,EAAC,CAAC;MAEjF,IAAMC,MAAM,GAAGJ,GAAG,C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I;QAE5BU,UAAU,CAAC,YAAM;UACf,MAAI,CAACT,kBAAkB,GAAG,KAAK;QACjC,CAAC,CAAC;MACJ,CAAC,CAAC,CACDU,KAAK,EAAE;IACZ;EAAC;EAAA;AAAA;AAGH,eAAetF,MAAM"}
1
+ {"version":3,"names":["Box3","MathUtils","TWEEN","Vector3","Camera","camera","controls","object","addEventListener","isTransitionPeriod","lookat","target","position","console","log","currentPos","pitch","box","setFromPoints","map","item","center","getCenter","size","getSize","halfDiagonal","length","maxDistance","Math","tan","fov","PI","cameraToCenterDistance","directionVector","clone","sub","normalize","lastPosition","multiplyScalar","add","lastLookat","caclTargetByPitch","subVectors","upVector","localPitchAxis","crossVectors","applyAxisAngle","degToRad","distance","distanceTo","newTarget","prevTarget","prevPosition","lastTarget","params","Promise","res","duration","moveOptions","onUpdate","onComplate","toArray","isTrigger","userInput","Array","isArray","caclCurrentPos","moveCameraTo","caclSingleCoordinate","fromArray","_","x","y","z","options","currentPoition","currentPositionInterpolation","copy","Tween","t","p","to","rotation","onStart","enabled","easing","Easing","Quadratic","InOut","rotationParent","currentPosition","lerpVectors","onComplete","setTimeout","start"],"sources":["../../src/camera/index.ts"],"sourcesContent":["import type { OrbitControls, PerspectiveCamera } from '@anov/3d-core'\nimport { Box3, MathUtils, TWEEN, Vector3 } from '@anov/3d-core'\n\ntype vector3Array = [number, number, number]\ninterface ChangeCameraPresetOptions {\n duration?: number\n onUpdate?: (params: { position: Vector3; lookat: Vector3 }) => void\n onStart?: () => void\n onComplate?: () => void\n}\n\nclass Camera {\n private camera: PerspectiveCamera\n private controls: OrbitControls\n private isTransitionPeriod = false\n\n constructor(camera: PerspectiveCamera, controls: OrbitControls) {\n this.camera = camera\n this.controls = controls\n\n this.controls.object = this.camera\n // this.handleChanged()\n }\n\n /**\n * handle camera changed\n */\n private handleChanged() {\n this.controls.addEventListener('change', () => {\n if (!this.isTransitionPeriod) {\n const lookat = this.controls.target\n const position = this.camera.position\n\n console.log('camera changed', lookat, position)\n }\n })\n }\n\n /**\n * caclCurrentPos\n * @param currentPos\n * @returns\n */\n private caclCurrentPos(currentPos: vector3Array[], pitch: number) {\n const box = new Box3()\n\n box.setFromPoints(currentPos.map(item => new Vector3(item[0], item[1], item[2])))\n\n const center = box.getCenter(new Vector3())\n const size = box.getSize(new Vector3())\n const halfDiagonal = size.length() * 0.5\n\n const maxDistance = halfDiagonal / Math.tan(this.camera.fov / 2 * Math.PI / 180)\n const cameraToCenterDistance = maxDistance\n const directionVector = (this.camera.position.clone()).sub(this.controls.target).normalize() // 相机指向物体中心的向量\n\n const lastPosition = directionVector.multiplyScalar(cameraToCenterDistance).add(center)\n const lastLookat = this.caclTargetByPitch(pitch, center, lastPosition)\n\n return {\n lastPosition,\n lastLookat,\n }\n }\n\n /**\n * caclTargetByPitch\n * @param pitch\n * @param target\n * @param position\n * @returns\n */\n private caclTargetByPitch(pitch: number, target: Vector3, position: Vector3) {\n const directionVector = new Vector3().subVectors(target, position)\n const upVector = new Vector3(0, 1, 0)\n const localPitchAxis = new Vector3().crossVectors(directionVector, upVector).normalize()\n\n directionVector.applyAxisAngle(localPitchAxis, MathUtils.degToRad(pitch))\n\n const distance = position.distanceTo(target)\n const newTarget = position.clone().add(directionVector.normalize().multiplyScalar(distance))\n\n return newTarget\n }\n\n /**\n * caclSingle Coordinate\n * @param prevTarget\n * @param prevPosition\n * @param lastTarget\n * @returns\n */\n private caclSingleCoordinate(prevTarget: Vector3, prevPosition: Vector3, lastTarget: Vector3) {\n const directionVector = lastTarget.clone().sub(prevTarget).normalize()\n return directionVector.multiplyScalar(lastTarget.distanceTo(prevTarget)).add(prevPosition)\n }\n\n /**\n * focus On Position\n * @param params\n */\n focus(params: { target: vector3Array | vector3Array[]; pitch?: number; duration?: number }) {\n return new Promise((res) => {\n const { target: position, pitch, duration } = params\n const moveOptions = () => ({\n duration: (duration && duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n // sendToMessage(MessageType.Event, 'onCameraChanged', EMessageStatus.Success, undefined, {\n // position: position.toArray(),\n // target: lookat.toArray(),\n // })\n },\n onComplate: () => {\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\n isTrigger: true,\n duration: params.duration ?? 0,\n userInput: true,\n pitch: pitch ?? 40,\n })\n },\n }) as ChangeCameraPresetOptions\n\n if (Array.isArray(position[0])) {\n const currentPos = position as vector3Array[]\n const { lastPosition, lastLookat } = this.caclCurrentPos(currentPos, 0)\n\n this.moveCameraTo(\n lastPosition,\n lastLookat,\n pitch,\n moveOptions(),\n )\n }\n else {\n const currentPos = position as vector3Array\n const lastPosition = this.caclSingleCoordinate(this.controls.target, this.camera.position, new Vector3().fromArray(currentPos))\n const lastLookat = this.caclTargetByPitch(0, new Vector3().fromArray(currentPos), lastPosition)\n\n this.moveCameraTo(\n lastPosition,\n lastLookat,\n pitch,\n moveOptions(),\n )\n }\n })\n }\n\n /**\n * set camera\n * @param params\n */\n set(params: { position: vector3Array; target: vector3Array; isTrigger?: boolean; duration?: number }) {\n return new Promise ((res, _) => {\n this.moveCameraTo(\n new Vector3(params.position[0], params.position[1], params.position[2]),\n new Vector3(params.target[0], params.target[1], params.target[2]),\n 0,\n {\n duration: (params.duration && params.duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n // params.isTrigger\n // && sendToMessage(MessageType.Event, 'onCameraChanged', EMessageStatus.Success, undefined, {\n // position: position.toArray(),\n // target: lookat.toArray(),\n // })\n },\n onComplate: () => {\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\n isTrigger: true,\n duration: params.duration ?? 0,\n userInput: true,\n })\n },\n })\n })\n }\n\n /**\n * get Camera info\n * @returns\n */\n get() {\n return {\n position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],\n target: [this.controls.target.x, this.controls.target.y, this.controls.target.z],\n }\n }\n\n /**\n * interpolation move camera\n * @param position\n * @param target\n * @param options\n */\n private moveCameraTo(position: Vector3, target: Vector3, pitch = 0, options?: ChangeCameraPresetOptions) {\n const currentPoition = this.camera.position.clone()\n const currentPositionInterpolation = new Vector3()\n\n if (options?.duration === 0) {\n this.camera.position.copy(position)\n this.controls.target.copy(target)\n\n options?.onComplate && options.onComplate()\n return\n }\n\n new TWEEN.Tween({ t: 0, lookat: this.controls.target.clone(), p: 0 }).to({ t: 1, lookat: target, p: (-this.camera.rotation.x + (pitch ? MathUtils.degToRad(-pitch) : 0)) }, options?.duration || 1000)\n .onStart(() => {\n options?.onStart && options.onStart()\n this.controls.enabled = false\n this.isTransitionPeriod = true\n })\n .easing(TWEEN.Easing.Quadratic.InOut)\n .onUpdate(({ t, lookat, p }) => {\n this.controls.target.copy(lookat)\n\n if (pitch)\n // @ts-ignore\n this.camera.rotationParent.x = p\n\n const currentPosition = currentPositionInterpolation.lerpVectors(currentPoition, position, t)\n this.camera.position.copy(currentPosition)\n options?.onUpdate && options.onUpdate({ position: currentPosition, lookat })\n })\n .onComplete(() => {\n options?.onComplate && options.onComplate()\n this.controls.enabled = true\n\n setTimeout(() => {\n this.isTransitionPeriod = false\n })\n })\n .start()\n }\n}\n\nexport default Camera"],"mappings":";;;;;;;AACA,SAASA,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,QAAQ,eAAe;AAAA,IAUzDC,MAAM;EAKV,gBAAYC,MAAyB,EAAEC,QAAuB,EAAE;IAAA;IAAA;IAAA;IAAA,4CAFnC,KAAK;IAGhC,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IAExB,IAAI,CAACA,QAAQ,CAACC,MAAM,GAAG,IAAI,CAACF,MAAM;IAClC;EACF;;EAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,yBAAwB;MAAA;MACtB,IAAI,CAACC,QAAQ,CAACE,gBAAgB,CAAC,QAAQ,EAAE,YAAM;QAC7C,IAAI,CAAC,KAAI,CAACC,kBAAkB,EAAE;UAC5B,IAAMC,MAAM,GAAG,KAAI,CAACJ,QAAQ,CAAC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C,GAAGS,CAAC;QAElC,IAAMU,eAAe,GAAGd,4BAA4B,CAACe,WAAW,CAAChB,cAAc,EAAE/D,QAAQ,EAAEmE,CAAC,CAAC;QAC7F,MAAI,CAAC1E,MAAM,CAACO,QAAQ,CAACiE,IAAI,CAACa,eAAe,CAAC;QAC1C,CAAAhB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEf,QAAQ,KAAIe,OAAO,CAACf,QAAQ,CAAC;UAAE/C,QAAQ,EAAE8E,eAAe;UAAEhF,MAAM,EAANA;QAAO,CAAC,CAAC;MAC9E,CAAC,CAAC,CACDkF,UAAU,CAAC,YAAM;QAChB,CAAAlB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEd,UAAU,KAAIc,OAAO,CAACd,UAAU,EAAE;QAC3C,MAAI,CAACtD,QAAQ,CAAC8E,OAAO,GAAG,IAAI;QAE5BS,UAAU,CAAC,YAAM;UACf,MAAI,CAACpF,kBAAkB,GAAG,KAAK;QACjC,CAAC,CAAC;MACJ,CAAC,CAAC,CACDqF,KAAK,EAAE;IACZ;EAAC;EAAA;AAAA;AAGH,eAAe1F,MAAM"}
@@ -81,9 +81,12 @@ var createSkySystem = function createSkySystem(date, latitude, longitude) {
81
81
  uniforms = _initsSkySystem2[2];
82
82
  var sunLight = initSunLight();
83
83
  var skyGroup = new Group();
84
- scene.add(sky);
84
+
85
+ // TODO: 工厂案例临时释
86
+ // scene!.add(sky)
85
87
  skyGroup.add(sunLight);
86
- scene.add(skyGroup);
88
+ // scene!.add(skyGroup)
89
+
87
90
  var move = function move(altitude, azimuth) {
88
91
  position.setFromSphericalCoords(sunRadius, MathUtils.degToRad(90 - MathUtils.radToDeg(altitude)), azimuth);
89
92
  uniforms.sunPosition.value.copy(position);
@@ -1 +1 @@
1
- {"version":3,"names":["DirectionalLight","Group","MathUtils","Vector3","lib","use","getLastValue","getSunPosition","Sky","initsSkySystem","options","sky","position","useScene","renderer","scale","setScalar","effectController","turbidity","rayleigh","mieCoefficient","mieDirectionalG","elevation","azimuth","exposure","uniforms","material","value","phi","degToRad","theta","setFromSphericalCoords","sunPosition","copy","initSunLight","opts","sunLight","color","intensity","castShadow","shadow","bias","mapSize","set","cam","camera","near","far","left","right","top","bottom","createSkySystem","date","latitude","longitude","sunRadius","scene","Error","skyGroup","add","move","altitude","radToDeg","x","Math","cos","z","sin","y","setDate","currentDate"],"sources":["../../../src/environment/sky/index.ts"],"sourcesContent":["import { DirectionalLight, Group, MathUtils, Vector3, lib, use } from '@anov/3d-core'\nimport { getLastValue } from '../../utils'\nimport { getSunPosition } from '../sun'\n\nconst Sky = lib.Sky\n\ntype SkySystemOption = {\n scalarCoefficient?: number\n turbidity?: number\n rayleigh?: number\n mieCoefficient?: number\n mieDirectionalG?: number\n elevation?: number\n azimuth?: number\n exposure?: number\n}\n\n/**\n * 天空盒 shader\n */\nconst initsSkySystem = (options?: SkySystemOption) => {\n const sky = new Sky()\n const position = new Vector3()\n const { renderer } = use.useScene()\n\n sky.scale.setScalar(450000)\n\n const effectController = {\n turbidity: 10,\n rayleigh: 3,\n mieCoefficient: 0.005,\n mieDirectionalG: 0.7,\n elevation: 2,\n azimuth: 180,\n exposure: 0.1,\n }\n // @ts-ignore\n const uniforms = sky.material.uniforms\n uniforms.turbidity.value = effectController.turbidity\n uniforms.rayleigh.value = effectController.rayleigh\n uniforms.mieCoefficient.value = effectController.mieCoefficient\n uniforms.mieDirectionalG.value = effectController.mieDirectionalG\n\n const phi = MathUtils.degToRad(90 - effectController.elevation)\n const theta = MathUtils.degToRad(effectController.azimuth)\n\n position.setFromSphericalCoords(1, phi, theta)\n uniforms.sunPosition.value.copy(position)\n\n return [sky, position, uniforms] as [typeof sky, typeof position, typeof uniforms]\n}\n\ntype SunLightOption = {\n color?: string\n intensity?: number\n bias?: number\n mapSize?: [number, number]\n\n near?: number\n far?: number\n left?: number\n right?: number\n top?: number\n bottom?: number\n}\n\n/**\n * create sun light\n * @param options\n * @returns\n */\nconst initSunLight = (options?: SunLightOption) => {\n const opts = options || {}\n\n const sunLight = new DirectionalLight(getLastValue(opts.color, 'white'), getLastValue(opts.intensity, 10))\n sunLight.castShadow = true\n\n sunLight.shadow.bias = getLastValue(opts.bias, -0.005)\n sunLight.shadow.mapSize.set(getLastValue(opts.mapSize?.[0], 1024 * 2), getLastValue(opts.mapSize?.[1], 1024 * 2))\n\n const cam = sunLight.shadow.camera\n cam.near = getLastValue(opts.near, 1)\n cam.far = getLastValue(opts.far, 10000)\n cam.left = getLastValue(opts.left, -1000)\n cam.right = getLastValue(opts.right, 1000)\n cam.top = getLastValue(opts.top, 1000)\n cam.bottom = getLastValue(opts.bottom, -1000)\n\n return sunLight\n}\n\n/**\n * create sky system\n * @param date\n * @param latitude\n * @param longitude\n * @returns\n */\nconst createSkySystem = (date: Date, latitude: number, longitude: number, sunRadius = 300) => {\n const { renderer, scene } = use.useScene()\n\n sunRadius = 300\n if (!renderer && !scene)\n throw new Error('renderer or scene is not exist')\n\n const [sky, position, uniforms] = initsSkySystem()\n const sunLight = initSunLight()\n const skyGroup = new Group() as (Group & { sunPosition: Vector3 })\n\n scene!.add(sky)\n skyGroup.add(sunLight)\n scene!.add(skyGroup)\n\n const move = (altitude: number, azimuth: number) => {\n position.setFromSphericalCoords(sunRadius, MathUtils.degToRad(90 - MathUtils.radToDeg(altitude)), azimuth)\n uniforms.sunPosition.value.copy(position)\n\n const x = sunRadius * (Math.cos(altitude)) * (Math.cos(azimuth))\n const z = sunRadius * (Math.cos(altitude)) * (Math.sin(azimuth))\n const y = sunRadius * (Math.sin(altitude))\n\n const sunPosition = new Vector3(x, y, z)\n skyGroup.sunPosition = sunPosition\n skyGroup.position.copy(position)\n\n return sunPosition\n }\n\n const { altitude, azimuth } = getSunPosition(date, latitude, longitude)\n move(altitude, azimuth)\n\n /**\n * set date\n * @param currentDate\n * @returns\n */\n const setDate = (currentDate?: Date) => {\n const { altitude, azimuth } = getSunPosition(currentDate || date, latitude, longitude)\n return move(altitude, azimuth)\n }\n\n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CAAC;AAED,eAAeyC,eAAe"}
1
+ {"version":3,"names":["DirectionalLight","Group","MathUtils","Vector3","lib","use","getLastValue","getSunPosition","Sky","initsSkySystem","options","sky","position","useScene","renderer","scale","setScalar","effectController","turbidity","rayleigh","mieCoefficient","mieDirectionalG","elevation","azimuth","exposure","uniforms","material","value","phi","degToRad","theta","setFromSphericalCoords","sunPosition","copy","initSunLight","opts","sunLight","color","intensity","castShadow","shadow","bias","mapSize","set","cam","camera","near","far","left","right","top","bottom","createSkySystem","date","latitude","longitude","sunRadius","scene","Error","skyGroup","add","move","altitude","radToDeg","x","Math","cos","z","sin","y","setDate","currentDate"],"sources":["../../../src/environment/sky/index.ts"],"sourcesContent":["import { DirectionalLight, Group, MathUtils, Vector3, lib, use } from '@anov/3d-core'\nimport { getLastValue } from '../../utils'\nimport { getSunPosition } from '../sun'\n\nconst Sky = lib.Sky\n\ntype SkySystemOption = {\n scalarCoefficient?: number\n turbidity?: number\n rayleigh?: number\n mieCoefficient?: number\n mieDirectionalG?: number\n elevation?: number\n azimuth?: number\n exposure?: number\n}\n\n/**\n * 天空盒 shader\n */\nconst initsSkySystem = (options?: SkySystemOption) => {\n const sky = new Sky()\n const position = new Vector3()\n const { renderer } = use.useScene()\n\n sky.scale.setScalar(450000)\n\n const effectController = {\n turbidity: 10,\n rayleigh: 3,\n mieCoefficient: 0.005,\n mieDirectionalG: 0.7,\n elevation: 2,\n azimuth: 180,\n exposure: 0.1,\n }\n // @ts-ignore\n const uniforms = sky.material.uniforms\n uniforms.turbidity.value = effectController.turbidity\n uniforms.rayleigh.value = effectController.rayleigh\n uniforms.mieCoefficient.value = effectController.mieCoefficient\n uniforms.mieDirectionalG.value = effectController.mieDirectionalG\n\n const phi = MathUtils.degToRad(90 - effectController.elevation)\n const theta = MathUtils.degToRad(effectController.azimuth)\n\n position.setFromSphericalCoords(1, phi, theta)\n uniforms.sunPosition.value.copy(position)\n\n return [sky, position, uniforms] as [typeof sky, typeof position, typeof uniforms]\n}\n\ntype SunLightOption = {\n color?: string\n intensity?: number\n bias?: number\n mapSize?: [number, number]\n\n near?: number\n far?: number\n left?: number\n right?: number\n top?: number\n bottom?: number\n}\n\n/**\n * create sun light\n * @param options\n * @returns\n */\nconst initSunLight = (options?: SunLightOption) => {\n const opts = options || {}\n\n const sunLight = new DirectionalLight(getLastValue(opts.color, 'white'), getLastValue(opts.intensity, 10))\n sunLight.castShadow = true\n\n sunLight.shadow.bias = getLastValue(opts.bias, -0.005)\n sunLight.shadow.mapSize.set(getLastValue(opts.mapSize?.[0], 1024 * 2), getLastValue(opts.mapSize?.[1], 1024 * 2))\n\n const cam = sunLight.shadow.camera\n cam.near = getLastValue(opts.near, 1)\n cam.far = getLastValue(opts.far, 10000)\n cam.left = getLastValue(opts.left, -1000)\n cam.right = getLastValue(opts.right, 1000)\n cam.top = getLastValue(opts.top, 1000)\n cam.bottom = getLastValue(opts.bottom, -1000)\n\n return sunLight\n}\n\n/**\n * create sky system\n * @param date\n * @param latitude\n * @param longitude\n * @returns\n */\nconst createSkySystem = (date: Date, latitude: number, longitude: number, sunRadius = 300) => {\n const { renderer, scene } = use.useScene()\n\n sunRadius = 300\n if (!renderer && !scene)\n throw new Error('renderer or scene is not exist')\n\n const [sky, position, uniforms] = initsSkySystem()\n const sunLight = initSunLight()\n const skyGroup = new Group() as (Group & { sunPosition: Vector3 })\n\n // TODO: 工厂案例临时释\n // scene!.add(sky)\n skyGroup.add(sunLight)\n // scene!.add(skyGroup)\n\n const move = (altitude: number, azimuth: number) => {\n position.setFromSphericalCoords(sunRadius, MathUtils.degToRad(90 - MathUtils.radToDeg(altitude)), azimuth)\n uniforms.sunPosition.value.copy(position)\n\n const x = sunRadius * (Math.cos(altitude)) * (Math.cos(azimuth))\n const z = sunRadius * (Math.cos(altitude)) * (Math.sin(azimuth))\n const y = sunRadius * (Math.sin(altitude))\n\n const sunPosition = new Vector3(x, y, z)\n skyGroup.sunPosition = sunPosition\n skyGroup.position.copy(position)\n\n return sunPosition\n }\n\n const { altitude, azimuth } = getSunPosition(date, latitude, longitude)\n move(altitude, azimuth)\n\n /**\n * set date\n * @param currentDate\n * @returns\n */\n const setDate = (currentDate?: Date) => {\n const { altitude, azimuth } = getSunPosition(currentDate || date, latitude, longitude)\n return move(altitude, azimuth)\n }\n\n return [setDate, skyGroup, sky] as [typeof setDate, Group & { sunPosition: Vector3 }, any]\n}\n\nexport default createSkySystem\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,EAAEC,GAAG,EAAEC,GAAG,QAAQ,eAAe;AACrF,SAASC,YAAY;AACrB,SAASC,cAAc;AAEvB,IAAMC,GAAG,GAAGJ,GAAG,CAACI,GAAG;AAanB;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAc,CAAIC,OAAyB,EAAK;EACpD,IAAMC,GAAG,GAAG,IAAIH,GAAG,EAAE;EACrB,IAAMI,QAAQ,GAAG,IAAIT,OAAO,EAAE;EAC9B,oBAAqBE,GAAG,CAACQ,QAAQ,EAAE;IAA3BC,QAAQ,iBAARA,QAAQ;EAEhBH,GAAG,CAACI,KAAK,CAACC,SAAS,CAAC,MAAM,CAAC;EAE3B,IAAMC,gBAAgB,GAAG;IACvBC,SAAS,EAAE,EAAE;IACbC,QAAQ,EAAE,CAAC;IACXC,cAAc,EAAE,KAAK;IACrBC,eAAe,EAAE,GAAG;IACpBC,SAAS,EAAE,CAAC;IACZC,OAAO,EAAE,GAAG;IACZC,QAAQ,EAAE;EACZ,CAAC;EACD;EACA,IAAMC,QAAQ,GAAGd,GAAG,CAACe,QAAQ,CAACD,QAAQ;EACtCA,QAAQ,CAACP,SAAS,CAACS,KAAK,GAAGV,gBAAgB,CAACC,SAAS;EACrDO,QAAQ,CAACN,QAAQ,CAACQ,KAAK,GAAGV,gBAAgB,CAACE,QAAQ;EACnDM,QAAQ,CAACL,cAAc,CAACO,KAAK,GAAGV,gBAAgB,CAACG,cAAc;EAC/DK,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C,QAAQ,EAAEvC,OAAO,CAAC;EAChC,CAAC;EAED,OAAO,CAAC+C,OAAO,EAAEX,QAAQ,EAAEhD,GAAG,CAAC;AACjC,CAAC;AAED,eAAeyC,eAAe"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { SceneControl } from '@anov/3d-core';
2
- import { mouseDraweLine } from './core/mouseDrawe';
3
2
  import { createSnow } from './environment/snow';
4
3
  import { createRain } from './environment/rain';
5
- import createCloud from './environment/cloud';
6
4
  import { initPostEffects } from './postEffects';
7
5
  import createHighSelectedTool from './postEffects/outlinePass';
8
6
  import { createSun } from './environment/sun';
@@ -18,7 +16,8 @@ import HeatMap from './heatmap/index';
18
16
  import SkyBox from './environment/skyBox';
19
17
  import Camera from './camera/index';
20
18
  import { RoundLineGeometry, createRoundLineWallMesh } from './line/round-curve';
19
+ import Fog2DMesh from './weather/fog2DMesh';
21
20
  export * from './scene';
22
21
  export { SceneControl, // todo remove
23
- mouseDraweLine, createRain, createSnow, createCloud, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, Poi, EPoiType, HeatMap, initPostEffects, // effect
24
- createHighSelectedTool, GridMaterial, SkyBox, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, };
22
+ createRain, createSnow, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, Poi, EPoiType, HeatMap, initPostEffects, // effect
23
+ createHighSelectedTool, GridMaterial, SkyBox, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, Fog2DMesh, };
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { SceneControl } from '@anov/3d-core';
2
- import { mouseDraweLine } from "./core/mouseDrawe";
3
2
  import { createSnow } from "./environment/snow";
4
3
  import { createRain } from "./environment/rain";
5
- import createCloud from "./environment/cloud";
6
4
  import { initPostEffects } from "./postEffects";
7
5
  import createHighSelectedTool from "./postEffects/outlinePass";
8
6
  import { createSun } from "./environment/sun";
@@ -18,10 +16,11 @@ import HeatMap from "./heatmap/index";
18
16
  import SkyBox from "./environment/skyBox";
19
17
  import Camera from "./camera/index";
20
18
  import { RoundLineGeometry, createRoundLineWallMesh } from "./line/round-curve";
19
+ import Fog2DMesh from "./weather/fog2DMesh";
21
20
  export * from "./scene";
22
21
  export { SceneControl,
23
22
  // todo remove
24
- mouseDraweLine, createRain, createSnow, createCloud, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, Poi, EPoiType, HeatMap, initPostEffects,
23
+ createRain, createSnow, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, Poi, EPoiType, HeatMap, initPostEffects,
25
24
  // effect
26
- createHighSelectedTool, GridMaterial, SkyBox, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh };
25
+ createHighSelectedTool, GridMaterial, SkyBox, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, Fog2DMesh };
27
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["SceneControl","mouseDraweLine","createSnow","createRain","createCloud","initPostEffects","createHighSelectedTool","createSun","GridMaterial","ViewHelper","createSkySystem","createVolumetricCloud","createSkyCloud","Snow","Rain","Poi","EPoiType","HeatMap","SkyBox","Camera","RoundLineGeometry","createRoundLineWallMesh"],"sources":["../src/index.ts"],"sourcesContent":["import { SceneControl } from '@anov/3d-core'\nimport { mouseDraweLine } from './core/mouseDrawe'\nimport { createSnow } from './environment/snow'\nimport { createRain } from './environment/rain'\nimport createCloud from './environment/cloud'\nimport { initPostEffects } from './postEffects'\nimport createHighSelectedTool from './postEffects/outlinePass'\nimport { createSun } from './environment/sun'\nimport GridMaterial from './material/pristineGridMaterial'\nimport ViewHelper from './helper/view'\nimport createSkySystem from './environment/sky'\nimport createVolumetricCloud from './environment/volumetricCloud/inex'\nimport createSkyCloud from './environment/shaderCloud/index'\nimport Snow from './environment/showShader'\nimport Rain from './environment/rainShader'\nimport Poi, { EPoiType } from './poi'\nimport HeatMap from './heatmap/index'\nimport SkyBox from './environment/skyBox'\nimport Camera from './camera/index'\nimport { RoundLineGeometry, createRoundLineWallMesh } from './line/round-curve'\n\nexport * from './scene'\n\nexport {\n SceneControl, // todo remove\n mouseDraweLine,\n createRain,\n createSnow,\n createCloud,\n createSun,\n createSkySystem,\n createVolumetricCloud,\n createSkyCloud,\n Snow,\n Rain,\n Poi, EPoiType,\n HeatMap,\n initPostEffects, // effect\n createHighSelectedTool,\n GridMaterial,\n SkyBox,\n ViewHelper,\n Camera,\n RoundLineGeometry,\n createRoundLineWallMesh,\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAe;AAC5C,SAASC,cAAc;AACvB,SAASC,UAAU;AACnB,SAASC,UAAU;AACnB,OAAOC,WAAW;AAClB,SAASC,eAAe;AACxB,OAAOC,sBAAsB;AAC7B,SAASC,SAAS;AAClB,OAAOC,YAAY;AACnB,OAAOC,UAAU;AACjB,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc;AACrB,OAAOC,IAAI;AACX,OAAOC,IAAI;AACX,OAAOC,GAAG,IAAIC,QAAQ;AACtB,OAAOC,OAAO;AACd,OAAOC,MAAM;AACb,OAAOC,MAAM;AACb,SAASC,iBAAiB,EAAEC,uBAAuB;AAEnD;AAEA,SACErB,YAAY;AAAE;AACdC,cAAc,EACdE,UAAU,EACVD,UAAU,EACVE,WAAW,EACXG,SAAS,EACTG,eAAe,EACfC,qBAAqB,EACrBC,cAAc,EACdC,IAAI,EACJC,IAAI,EACJC,GAAG,EAAEC,QAAQ,EACbC,OAAO,EACPZ,eAAe;AAAE;AACjBC,sBAAsB,EACtBE,YAAY,EACZU,MAAM,EACNT,UAAU,EACVU,MAAM,EACNC,iBAAiB,EACjBC,uBAAuB"}
1
+ {"version":3,"names":["SceneControl","createSnow","createRain","initPostEffects","createHighSelectedTool","createSun","GridMaterial","ViewHelper","createSkySystem","createVolumetricCloud","createSkyCloud","Snow","Rain","Poi","EPoiType","HeatMap","SkyBox","Camera","RoundLineGeometry","createRoundLineWallMesh","Fog2DMesh"],"sources":["../src/index.ts"],"sourcesContent":["import { SceneControl } from '@anov/3d-core'\nimport { createSnow } from './environment/snow'\nimport { createRain } from './environment/rain'\nimport { initPostEffects } from './postEffects'\nimport createHighSelectedTool from './postEffects/outlinePass'\nimport { createSun } from './environment/sun'\nimport GridMaterial from './material/pristineGridMaterial'\nimport ViewHelper from './helper/view'\nimport createSkySystem from './environment/sky'\nimport createVolumetricCloud from './environment/volumetricCloud/inex'\nimport createSkyCloud from './environment/shaderCloud/index'\nimport Snow from './environment/showShader'\nimport Rain from './environment/rainShader'\nimport Poi, { EPoiType } from './poi'\nimport HeatMap from './heatmap/index'\nimport SkyBox from './environment/skyBox'\nimport Camera from './camera/index'\nimport { RoundLineGeometry, createRoundLineWallMesh } from './line/round-curve'\nimport Fog2DMesh from './weather/fog2DMesh'\n\nexport * from './scene'\n\nexport {\n SceneControl, // todo remove\n createRain,\n createSnow,\n createSun,\n createSkySystem,\n createVolumetricCloud,\n createSkyCloud,\n Snow,\n Rain,\n Poi, EPoiType,\n HeatMap,\n initPostEffects, // effect\n createHighSelectedTool,\n GridMaterial,\n SkyBox,\n ViewHelper,\n Camera,\n RoundLineGeometry,\n createRoundLineWallMesh,\n Fog2DMesh,\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAe;AAC5C,SAASC,UAAU;AACnB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,OAAOC,sBAAsB;AAC7B,SAASC,SAAS;AAClB,OAAOC,YAAY;AACnB,OAAOC,UAAU;AACjB,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc;AACrB,OAAOC,IAAI;AACX,OAAOC,IAAI;AACX,OAAOC,GAAG,IAAIC,QAAQ;AACtB,OAAOC,OAAO;AACd,OAAOC,MAAM;AACb,OAAOC,MAAM;AACb,SAASC,iBAAiB,EAAEC,uBAAuB;AACnD,OAAOC,SAAS;AAEhB;AAEA,SACEpB,YAAY;AAAE;AACdE,UAAU,EACVD,UAAU,EACVI,SAAS,EACTG,eAAe,EACfC,qBAAqB,EACrBC,cAAc,EACdC,IAAI,EACJC,IAAI,EACJC,GAAG,EAAEC,QAAQ,EACbC,OAAO,EACPZ,eAAe;AAAE;AACjBC,sBAAsB,EACtBE,YAAY,EACZU,MAAM,EACNT,UAAU,EACVU,MAAM,EACNC,iBAAiB,EACjBC,uBAAuB,EACvBC,SAAS"}
@@ -7,5 +7,6 @@ declare class AnovSprite extends Sprite {
7
7
  constructor(type: EPoiType, data: string, option: IOption);
8
8
  private create;
9
9
  private setAttribute;
10
+ addEventListener(type: string, cb: any): () => void;
10
11
  }
11
12
  export default AnovSprite;
@@ -7,6 +7,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
8
  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); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
11
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
10
12
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
13
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
14
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -127,6 +129,15 @@ var AnovSprite = /*#__PURE__*/function (_Sprite) {
127
129
  hasExecuted = true;
128
130
  };
129
131
  }
132
+ }, {
133
+ key: "addEventListener",
134
+ value: function addEventListener(type, cb) {
135
+ var _this4 = this;
136
+ _get(_getPrototypeOf(AnovSprite.prototype), "addEventListener", this).call(this, type, cb);
137
+ return function () {
138
+ return _get(_getPrototypeOf(AnovSprite.prototype), "removeEventListener", _this4).call(_this4, type, cb);
139
+ };
140
+ }
130
141
  }]);
131
142
  return AnovSprite;
132
143
  }(Sprite);
@@ -1 +1 @@
1
- {"version":3,"names":["Sprite","SpriteMaterial","Texture","Vector2","gsap","getCanvas","EAnimationType","POI_IMG","DafultOption","width","height","img","scale","animation","type","appear","duration","AnovSprite","data","option","map","poiType","create","center","setX","setZ","visible","setMaterial","canvas","isFadeOrAppearAnimation","fadeIn","opacity","texture","needsUpdate","material","setAttribute","hasExecuted","onAfterRender","setTimeout","to","repeat","ease","grow","y"],"sources":["../../../src/poi/core/Sprite.ts"],"sourcesContent":["import { Sprite, SpriteMaterial, Texture, Vector2 } from '@anov/3d-core'\nimport gsap from 'gsap'\nimport { getCanvas } from '../utils/canvas'\nimport { EAnimationType } from '../utils/type'\nimport type { EPoiType, IOption } from '../utils/type'\nimport { POI_IMG } from '../utils/base64'\n\nconst DafultOption = {\n width: 200,\n height: 260,\n img: POI_IMG,\n scale: 60,\n animation: {\n type: EAnimationType.appear,\n duration: 0.3,\n },\n}\n\nclass AnovSprite extends Sprite {\n poiType: EPoiType\n data!: any\n option!: IOption\n constructor(type: EPoiType, data: string, option: IOption) {\n super(new SpriteMaterial({ map: null }))\n this.poiType = type\n this.data = data\n this.option = { ...DafultOption, ...option }\n this.create()\n }\n\n private create() {\n const { scale = 1, animation } = this.option\n // 精灵的锚点\n this.center = new Vector2(0.5, 0)\n this.scale.setX(scale)\n this.scale.setZ(scale)\n this.visible = false\n // 异步生成材质\n const setMaterial = async () => {\n const canvas = await getCanvas(this.data, this.option)\n // 判断条件\n const isFadeOrAppearAnimation = animation?.type === EAnimationType.fadeIn || animation?.type === EAnimationType.appear\n // 根据条件设置 opacity 的值\n const opacity = isFadeOrAppearAnimation ? 0 : 1\n // 生成精灵模型\n const texture = new Texture(canvas)\n texture.needsUpdate = true\n this.material = new SpriteMaterial({ map: texture, opacity })\n this.visible = true\n }\n setMaterial()\n this.setAttribute()\n }\n\n private setAttribute() {\n let hasExecuted = false\n // 执行渐显、打印内容等操作\n this.onAfterRender = () => {\n if (hasExecuted)\n return\n setTimeout(() => {\n const { animation } = this.option\n if (animation?.type === EAnimationType.fadeIn || animation?.type === EAnimationType.appear) {\n gsap.to(this.material, {\n opacity: 1,\n ...animation,\n repeat: 0,\n ease: 'none',\n })\n }\n if (animation?.type === EAnimationType.grow || animation?.type === EAnimationType.appear) {\n gsap.to(this.scale, {\n y: this.option.scale,\n ...animation,\n repeat: 0,\n ease: 'power2.out',\n })\n }\n })\n hasExecuted = true\n }\n }\n}\n\nexport default AnovSprite"],"mappings":";+CACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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UACA,IAAI,CAAA5B,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEC,IAAI,MAAKR,cAAc,CAACoC,IAAI,IAAI,CAAA7B,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEC,IAAI,MAAKR,cAAc,CAACS,MAAM,EAAE;YACxFX,IAAI,CAACmC,EAAE,CAAC,MAAI,CAAC3B,KAAK;cAChB+B,CAAC,EAAE,MAAI,CAACxB,MAAM,CAACP;YAAK,GACjBC,SAAS;cACZ2B,MAAM,EAAE,CAAC;cACTC,IAAI,EAAE;YAAY,GAClB;UACJ;QACF,CAAC,CAAC;QACFL,WAAW,GAAG,IAAI;MACpB,CAAC;IACH;EAAC;EAAA;AAAA,EA/DsBpC,MAAM;AAkE/B,eAAeiB,UAAU"}
1
+ {"version":3,"names":["Sprite","SpriteMaterial","Texture","Vector2","gsap","getCanvas","EAnimationType","POI_IMG","DafultOption","width","height","img","scale","animation","type","appear","duration","AnovSprite","data","option","map","poiType","create","center","setX","setZ","visible","setMaterial","canvas","isFadeOrAppearAnimation","fadeIn","opacity","texture","needsUpdate","material","setAttribute","hasExecuted","onAfterRender","setTimeout","to","repeat","ease","grow","y","cb"],"sources":["../../../src/poi/core/Sprite.ts"],"sourcesContent":["import { Sprite, SpriteMaterial, Texture, Vector2 } from '@anov/3d-core'\nimport gsap from 'gsap'\nimport { getCanvas } from '../utils/canvas'\nimport { EAnimationType } from '../utils/type'\nimport type { EPoiType, IOption } from '../utils/type'\nimport { POI_IMG } from '../utils/base64'\n\nconst DafultOption = {\n width: 200,\n height: 260,\n img: POI_IMG,\n scale: 60,\n animation: {\n type: EAnimationType.appear,\n duration: 0.3,\n },\n}\n\nclass AnovSprite extends Sprite {\n poiType: EPoiType\n data!: any\n option!: IOption\n constructor(type: EPoiType, data: string, option: IOption) {\n super(new SpriteMaterial({ map: null }))\n this.poiType = type\n this.data = data\n this.option = { ...DafultOption, ...option }\n this.create()\n }\n\n private create() {\n const { scale = 1, animation } = this.option\n // 精灵的锚点\n this.center = new Vector2(0.5, 0)\n this.scale.setX(scale)\n this.scale.setZ(scale)\n this.visible = false\n // 异步生成材质\n const setMaterial = async () => {\n const canvas = await getCanvas(this.data, this.option)\n // 判断条件\n const isFadeOrAppearAnimation = animation?.type === EAnimationType.fadeIn || animation?.type === EAnimationType.appear\n // 根据条件设置 opacity 的值\n const opacity = isFadeOrAppearAnimation ? 0 : 1\n // 生成精灵模型\n const texture = new Texture(canvas)\n texture.needsUpdate = true\n this.material = new SpriteMaterial({ map: texture, opacity })\n this.visible = true\n }\n setMaterial()\n this.setAttribute()\n }\n\n private setAttribute() {\n let hasExecuted = false\n // 执行渐显、打印内容等操作\n this.onAfterRender = () => {\n if (hasExecuted)\n return\n setTimeout(() => {\n const { animation } = this.option\n if (animation?.type === EAnimationType.fadeIn || animation?.type === EAnimationType.appear) {\n gsap.to(this.material, {\n opacity: 1,\n ...animation,\n repeat: 0,\n ease: 'none',\n })\n }\n if (animation?.type === EAnimationType.grow || animation?.type === EAnimationType.appear) {\n gsap.to(this.scale, {\n y: this.option.scale,\n ...animation,\n repeat: 0,\n ease: 'power2.out',\n })\n }\n })\n hasExecuted = true\n }\n }\n\n public addEventListener(type: string, cb: any) {\n super.addEventListener(type, cb)\n return () => super.removeEventListener(type, cb)\n }\n}\n\nexport default AnovSprite"],"mappings":";+CACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AADA,SAASA,MAAM,EAAEC,cAAc,EAAEC,OAAO,EAAEC,OAAO,QAAQ,eAAe;AACxE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS;AAClB,SAASC,cAAc;AAEvB,SAASC,OAAO;AAEhB,IAAMC,YAAY,GAAG;EACnBC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXC,GAAG,EAAEJ,OAAO;EACZK,KAAK,EAAE,EAAE;EACTC,S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ACZ2B,MAAM,EAAE,CAAC;cACTC,IAAI,EAAE;YAAY,GAClB;UACJ;QACF,CAAC,CAAC;QACFL,WAAW,GAAG,IAAI;MACpB,CAAC;IACH;EAAC;IAAA;IAAA,OAED,0BAAwBtB,IAAY,EAAE8B,EAAO,EAAE;MAAA;MAC7C,iFAAuB9B,IAAI,EAAE8B,EAAE;MAC/B,OAAO;QAAA,+FAAgC9B,IAAI,EAAE8B,EAAE;MAAA,CAAC;IAClD;EAAC;EAAA;AAAA,EApEsB5C,MAAM;AAuE/B,eAAeiB,UAAU"}
@@ -13,13 +13,13 @@ export declare const getBasePoiStyle: () => {
13
13
  export declare const getPanelStyle: () => {
14
14
  container: {
15
15
  width: string;
16
- height: string;
17
- backgroundImage: string;
18
- backgroundSize: string;
19
- backgroundRepeat: string;
16
+ 'min-height': string;
20
17
  color: string;
21
18
  pointerEvents: string;
22
19
  cursor: string;
20
+ 'border-image-source': string;
21
+ 'border-image-slice': string;
22
+ 'border-image-width': string;
23
23
  };
24
24
  title: {
25
25
  boxSizing: string;
@@ -16,14 +16,18 @@ export var getBasePoiStyle = function getBasePoiStyle() {
16
16
  export var getPanelStyle = function getPanelStyle() {
17
17
  return {
18
18
  container: {
19
- width: '458px',
20
- height: '202px',
21
- backgroundImage: "url(".concat(PANEL_IMG, ")"),
22
- backgroundSize: '100% 100%',
23
- backgroundRepeat: 'no-repeat',
24
- color: '#fff',
25
- pointerEvents: 'auto',
26
- cursor: 'pointer'
19
+ 'width': '520px',
20
+ 'min-height': '220px',
21
+ // 'backgroundImage': `url(${PANEL_IMG})`,
22
+ // 'backgroundSize': '100% 100%',
23
+ // 'backgroundRepeat': 'no-repeat',
24
+ 'color': '#fff',
25
+ 'pointerEvents': 'auto',
26
+ 'cursor': 'pointer',
27
+ 'border-image-source': "url(".concat(PANEL_IMG, ")"),
28
+ 'border-image-slice': '100 38 10 fill',
29
+ /* 九宫格裁剪,填充方式为拉伸 */
30
+ 'border-image-width': '100px 38px 10px'
27
31
  },
28
32
  title: {
29
33
  boxSizing: 'border-box',
@@ -1 +1 @@
1
- {"version":3,"names":["PANEL_IMG","PERSON_IMG","getBasePoiStyle","backgroundImage","minWidth","backgroundSize","backgroundRepeat","fontSize","color","fontWeight","boxSizing","padding","pointerEvents","getPanelStyle","container","width","height","cursor","title","content","lineHeight"],"sources":["../../../src/poi/utils/css.ts"],"sourcesContent":["import { PANEL_IMG, PERSON_IMG } from './base64'\n\nexport const getBasePoiStyle = () => {\n return {\n backgroundImage: `url(${PERSON_IMG})`,\n minWidth: '110px',\n backgroundSize: '100% 100%',\n backgroundRepeat: 'no-repeat',\n fontSize: '18px',\n color: '#fff',\n fontWeight: 'bold',\n boxSizing: 'border-box',\n padding: '2px 20px 10px 45px',\n pointerEvents: 'auto',\n }\n}\n\nexport const getPanelStyle = () => {\n return {\n container: {\n width: '458px',\n height: '202px',\n backgroundImage: `url(${PANEL_IMG})`,\n backgroundSize: '100% 100%',\n backgroundRepeat: 'no-repeat',\n color: '#fff',\n pointerEvents: 'auto',\n cursor: 'pointer',\n },\n title: {\n boxSizing: 'border-box',\n padding: '8px 15px 0 35px',\n fontSize: '26px',\n fontWeight: 'bold',\n },\n content: {\n padding: '26px 24px 10px 35px',\n fontSize: '16px',\n lineHeight: '30px',\n },\n }\n}"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU;AAE9B,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAe,GAAS;EACnC,OAAO;IACLC,eAAe,gBAASF,UAAU,MAAG;IACrCG,QAAQ,EAAE,OAAO;IACjBC,cAAc,EAAE,WAAW;IAC3BC,gBAAgB,EAAE,WAAW;IAC7BC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,UAAU,EAAE,MAAM;IAClBC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,oBAAoB;IAC7BC,aAAa,EAAE;EACjB,CAAC;AACH,CAAC;AAED,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAa,GAAS;EACjC,OAAO;IACLC,SAAS,EAAE;MACTC,KAAK,EAAE,OAAO;MACdC,MAAM,EAAE,OAAO;MACfb,eAAe,gBAASH,SAAS,MAAG;MACpCK,cAAc,EAAE,WAAW;MAC3BC,gBAAgB,EAAE,WAAW;MAC7BE,KAAK,EAAE,MAAM;MACbI,aAAa,EAAE,MAAM;MACrBK,MAAM,EAAE;IACV,CAAC;IACDC,KAAK,EAAE;MACLR,SAAS,EAAE,YAAY;MACvBC,OAAO,EAAE,iBAAiB;MAC1BJ,QAAQ,EAAE,MAAM;MAChBE,UAAU,EAAE;IACd,CAAC;IACDU,OAAO,EAAE;MACPR,OAAO,EAAE,qBAAqB;MAC9BJ,QAAQ,EAAE,MAAM;MAChBa,UAAU,EAAE;IACd;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["PANEL_IMG","PERSON_IMG","getBasePoiStyle","backgroundImage","minWidth","backgroundSize","backgroundRepeat","fontSize","color","fontWeight","boxSizing","padding","pointerEvents","getPanelStyle","container","title","content","lineHeight"],"sources":["../../../src/poi/utils/css.ts"],"sourcesContent":["import { PANEL_IMG, PERSON_IMG } from './base64'\n\nexport const getBasePoiStyle = () => {\n return {\n backgroundImage: `url(${PERSON_IMG})`,\n minWidth: '110px',\n backgroundSize: '100% 100%',\n backgroundRepeat: 'no-repeat',\n fontSize: '18px',\n color: '#fff',\n fontWeight: 'bold',\n boxSizing: 'border-box',\n padding: '2px 20px 10px 45px',\n pointerEvents: 'auto',\n }\n}\n\nexport const getPanelStyle = () => {\n return {\n container: {\n 'width': '520px',\n 'min-height': '220px',\n // 'backgroundImage': `url(${PANEL_IMG})`,\n // 'backgroundSize': '100% 100%',\n // 'backgroundRepeat': 'no-repeat',\n 'color': '#fff',\n 'pointerEvents': 'auto',\n 'cursor': 'pointer',\n 'border-image-source': `url(${PANEL_IMG})`,\n 'border-image-slice': '100 38 10 fill', /* 九宫格裁剪,填充方式为拉伸 */\n 'border-image-width': '100px 38px 10px',\n },\n title: {\n boxSizing: 'border-box',\n padding: '8px 15px 0 35px',\n fontSize: '26px',\n fontWeight: 'bold',\n },\n content: {\n padding: '26px 24px 10px 35px',\n fontSize: '16px',\n lineHeight: '30px',\n },\n }\n}"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU;AAE9B,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAe,GAAS;EACnC,OAAO;IACLC,eAAe,gBAASF,UAAU,MAAG;IACrCG,QAAQ,EAAE,OAAO;IACjBC,cAAc,EAAE,WAAW;IAC3BC,gBAAgB,EAAE,WAAW;IAC7BC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,UAAU,EAAE,MAAM;IAClBC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,oBAAoB;IAC7BC,aAAa,EAAE;EACjB,CAAC;AACH,CAAC;AAED,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAa,GAAS;EACjC,OAAO;IACLC,SAAS,EAAE;MACT,OAAO,EAAE,OAAO;MAChB,YAAY,EAAE,OAAO;MACrB;MACA;MACA;MACA,OAAO,EAAE,MAAM;MACf,eAAe,EAAE,MAAM;MACvB,QAAQ,EAAE,SAAS;MACnB,qBAAqB,gBAASd,SAAS,MAAG;MAC1C,oBAAoB,EAAE,gBAAgB;MAAE;MACxC,oBAAoB,EAAE;IACxB,CAAC;IACDe,KAAK,EAAE;MACLL,SAAS,EAAE,YAAY;MACvBC,OAAO,EAAE,iBAAiB;MAC1BJ,QAAQ,EAAE,MAAM;MAChBE,UAAU,EAAE;IACd,CAAC;IACDO,OAAO,EAAE;MACPL,OAAO,EAAE,qBAAqB;MAC9BJ,QAAQ,EAAE,MAAM;MAChBU,UAAU,EAAE;IACd;EACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Mesh } from '@anov/3d-core';
2
+ interface Fog2DMeshOptions {
3
+ color?: [number, number, number];
4
+ alpha?: number;
5
+ speed?: number;
6
+ }
7
+ declare class Fog2DMesh extends Mesh {
8
+ private speed;
9
+ constructor(ops?: Fog2DMeshOptions);
10
+ setColor(color: [number, number, number]): void;
11
+ setAlpha(alpha: number): void;
12
+ setSpeed(speed: number): void;
13
+ }
14
+ export default Fog2DMesh;
@@ -0,0 +1,77 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
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
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ import { Mesh, PlaneGeometry, ShaderMaterial, use } from '@anov/3d-core';
16
+ import { frag as fragmentShader, vert as vertexShader } from "./glsl/fog";
17
+ var fog2dShaderPass = {
18
+ uniforms: {
19
+ iTime: {
20
+ value: 0
21
+ },
22
+ fogcolor: {
23
+ value: [0.9, 0.9, 0.9]
24
+ },
25
+ alpha: {
26
+ value: 0.5
27
+ }
28
+ },
29
+ vertexShader: vertexShader,
30
+ fragmentShader: fragmentShader
31
+ };
32
+ var Fog2DMesh = /*#__PURE__*/function (_Mesh) {
33
+ _inherits(Fog2DMesh, _Mesh);
34
+ var _super = _createSuper(Fog2DMesh);
35
+ function Fog2DMesh(ops) {
36
+ var _this;
37
+ _classCallCheck(this, Fog2DMesh);
38
+ _this = _super.call(this);
39
+ _defineProperty(_assertThisInitialized(_this), "speed", 0.01);
40
+ _this.geometry = new PlaneGeometry(10, 10);
41
+ fog2dShaderPass.uniforms.fogcolor.value = (ops === null || ops === void 0 ? void 0 : ops.color) || [0.9, 0.9, 0.9];
42
+ fog2dShaderPass.uniforms.alpha.value = (ops === null || ops === void 0 ? void 0 : ops.alpha) || 0.5;
43
+ _this.speed = (ops === null || ops === void 0 ? void 0 : ops.speed) || 0.01;
44
+ _this.material = new ShaderMaterial({
45
+ uniforms: fog2dShaderPass.uniforms,
46
+ vertexShader: fog2dShaderPass.vertexShader,
47
+ fragmentShader: fog2dShaderPass.fragmentShader,
48
+ side: 2,
49
+ transparent: true,
50
+ depthWrite: false
51
+ });
52
+ _this.renderOrder = 1;
53
+ use.useframe(function () {
54
+ fog2dShaderPass.uniforms.iTime.value += _this.speed;
55
+ });
56
+ return _this;
57
+ }
58
+ _createClass(Fog2DMesh, [{
59
+ key: "setColor",
60
+ value: function setColor(color) {
61
+ fog2dShaderPass.uniforms.fogcolor.value = color;
62
+ }
63
+ }, {
64
+ key: "setAlpha",
65
+ value: function setAlpha(alpha) {
66
+ fog2dShaderPass.uniforms.alpha.value = alpha;
67
+ }
68
+ }, {
69
+ key: "setSpeed",
70
+ value: function setSpeed(speed) {
71
+ this.speed = speed;
72
+ }
73
+ }]);
74
+ return Fog2DMesh;
75
+ }(Mesh);
76
+ export default Fog2DMesh;
77
+ //# sourceMappingURL=fog2DMesh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Mesh","PlaneGeometry","ShaderMaterial","use","frag","fragmentShader","vert","vertexShader","fog2dShaderPass","uniforms","iTime","value","fogcolor","alpha","Fog2DMesh","ops","geometry","color","speed","material","side","transparent","depthWrite","renderOrder","useframe"],"sources":["../../src/weather/fog2DMesh.ts"],"sourcesContent":["import { Mesh, PlaneGeometry, ShaderMaterial, use } from '@anov/3d-core'\nimport { frag as fragmentShader, vert as vertexShader } from './glsl/fog'\n\nconst fog2dShaderPass = {\n uniforms: {\n iTime: { value: 0 },\n fogcolor: { value: [0.9, 0.9, 0.9] },\n alpha: { value: 0.5 },\n },\n\n vertexShader,\n fragmentShader,\n}\n\ninterface Fog2DMeshOptions {\n color?: [number, number, number]\n alpha?: number\n speed?: number\n}\n\nclass Fog2DMesh extends Mesh {\n private speed = 0.01\n\n constructor(ops?: Fog2DMeshOptions) {\n super()\n this.geometry = new PlaneGeometry(10, 10)\n\n fog2dShaderPass.uniforms.fogcolor.value = ops?.color || [0.9, 0.9, 0.9]\n fog2dShaderPass.uniforms.alpha.value = ops?.alpha || 0.5\n this.speed = ops?.speed || 0.01\n\n this.material = new ShaderMaterial({\n uniforms: fog2dShaderPass.uniforms,\n vertexShader: fog2dShaderPass.vertexShader,\n fragmentShader: fog2dShaderPass.fragmentShader,\n side: 2,\n transparent: true,\n depthWrite: false,\n })\n this.renderOrder = 1\n\n use.useframe(() => {\n fog2dShaderPass.uniforms.iTime.value += this.speed\n })\n }\n\n setColor(color: [number, number, number]) {\n fog2dShaderPass.uniforms.fogcolor.value = color\n }\n\n setAlpha(alpha: number) {\n fog2dShaderPass.uniforms.alpha.value = alpha\n }\n\n setSpeed(speed: number) {\n this.speed = speed\n }\n}\n\nexport default Fog2DMesh"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,IAAI,EAAEC,aAAa,EAAEC,cAAc,EAAEC,GAAG,QAAQ,eAAe;AACxE,SAASC,IAAI,IAAIC,cAAc,EAAEC,IAAI,IAAIC,YAAY;AAErD,IAAMC,eAAe,GAAG;EACtBC,QAAQ,EAAE;IACRC,KAAK,EAAE;MAAEC,KAAK,EAAE;IAAE,CAAC;IACnBC,QAAQ,EAAE;MAAED,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;I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BAASJ,KAAa,EAAE;MACtBL,eAAe,CAACC,QAAQ,CAACI,KAAK,CAACF,KAAK,GAAGE,KAAK;IAC9C;EAAC;IAAA;IAAA,OAED,kBAASK,KAAa,EAAE;MACtB,IAAI,CAACA,KAAK,GAAGA,KAAK;IACpB;EAAC;EAAA;AAAA,EApCqBlB,IAAI;AAuC5B,eAAec,SAAS"}
@@ -0,0 +1,2 @@
1
+ export declare const vert = "\nvarying highp vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = vec4(position, 1.0);\n}\n\n";
2
+ export declare const frag = "\nuniform vec3 fogcolor;\nuniform float iTime;\nuniform float alpha;\n\nvarying highp vec2 vUv;\n\nfloat random(vec2 _st) {\n return fract(sin(dot(_st.xy, vec2(0.630, 0.710))) *\n 43759.329);\n}\n\n//\u67CF\u6797\u566A\u58F0\nfloat noise(vec2 _st) {\n vec2 i = floor(_st);\n vec2 f = fract(_st);\n\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(a, b, u.x) +\n (c - a) * u.y * (1.0 - u.x) +\n (d - b) * u.x * u.y;\n}\n\n#define NUM_OCTAVES 6\n\n//\u5E03\u6717\u5206\u5F62\nfloat fbm(vec2 _st) {\n float v = 0.0;\n float a = 0.5;\n vec2 shift = vec2(100.0, 100.0);\n mat2 rot = mat2(cos(0.5), sin(0.5), -sin(0.5), cos(0.50));\n\n for(int i = 0; i < NUM_OCTAVES; ++i) {\n v += a * noise(_st);\n //_st = mul(_st, rot) * 2.0 + shift;\n _st = _st * rot * 2.0 + shift;\n a *= 0.5;\n }\n return v;\n}\n\nvec3 FilterColor(vec3 color1, vec3 color2) {\n //\u6EE4\u8272\n return 1.0 - (1.0 - color1) * (1.0 - color2);\n}\n\n// -----------------------------------------------\u95EA\u7535\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n vec2 uv = vUv;\n vec3 backcolor = vec3(0.);\n\n uv.y = 1.0 - uv.y;\n\n vec2 st = uv * 10.0;\n\n st.x += iTime * 0.1;\n st.y -= iTime * 0.2;\n\n vec3 color;\n vec2 q;\n\n q.x = fbm(st + 0.00 * iTime * 5.0);\n q.y = fbm(st + vec2(1.0, 1.0));\n\n vec2 r;\n r.x = fbm(st + 1.0 * q + vec2(1.7, 9.2) + 0.15 * iTime * 5.0);\n r.y = fbm(st + 1.0 * q + vec2(8.3, 2.8) + 0.126 * iTime * 5.0);\n\n float f = fbm(st + r);\n\n color = mix(vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0), clamp((f * f) * 4.0, 0.0, 1.0));\n color = mix(color, vec3(1.0, 1.0, 1.0), clamp(length(q), 0.0, 1.0));\n color = mix(color, vec3(1.0, 1.0, 1.0), clamp(length(r.x), 0.0, 1.0));\n vec3 cloud = vec3((f * f * f + 0.3 * f * f + 0.5 * f) * color);\n\n fragColor = vec4(FilterColor(cloud * fogcolor, backcolor), alpha);\n\n}\n\nvoid main() {\n vec2 fragCoord = gl_FragCoord.xy;\n mainImage(gl_FragColor, fragCoord);\n}\n";