@aibee/crc-bmap 0.0.90 → 0.0.91
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/example/src/main.ts +2 -2
- package/lib/bmap.cjs.min.js +16 -4
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +77 -11
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +16 -4
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +16 -4
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/elements/graphic.d.ts +4 -0
- package/lib/src/factory/material.d.ts +1 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -500,7 +500,8 @@ import {
|
|
|
500
500
|
Box3,
|
|
501
501
|
Vector3 as Vector32,
|
|
502
502
|
BufferGeometry,
|
|
503
|
-
LineSegments
|
|
503
|
+
LineSegments,
|
|
504
|
+
Ray
|
|
504
505
|
} from "three";
|
|
505
506
|
var defaultOptions = {
|
|
506
507
|
id: "",
|
|
@@ -642,7 +643,7 @@ var Graphic = class extends Object3D {
|
|
|
642
643
|
}
|
|
643
644
|
getPosition() {
|
|
644
645
|
const center2 = this.getCenter();
|
|
645
|
-
center2.setZ(center2.z + this.options.height);
|
|
646
|
+
center2.setZ(center2.z + this.options.height / 2);
|
|
646
647
|
return center2;
|
|
647
648
|
}
|
|
648
649
|
init() {
|
|
@@ -685,31 +686,67 @@ var Graphic = class extends Object3D {
|
|
|
685
686
|
this.material = [material, material1];
|
|
686
687
|
return [material, material1];
|
|
687
688
|
}
|
|
689
|
+
// createMesh(pos: Vector3, color = 0xff0000) {
|
|
690
|
+
// const geometry = new BoxGeometry(1, 1, 1)
|
|
691
|
+
// const material = new MeshBasicMaterial({ color })
|
|
692
|
+
// const mesh = new Mesh(geometry, material)
|
|
693
|
+
// mesh.position.copy(pos)
|
|
694
|
+
// this.context.scene.add(mesh)
|
|
695
|
+
// }
|
|
696
|
+
// createLine(points: Vector3[], color = 0xff0000) {
|
|
697
|
+
// const material = new LineBasicMaterial({
|
|
698
|
+
// color: color
|
|
699
|
+
// });
|
|
700
|
+
// const geometry = new BufferGeometry().setFromPoints(points);
|
|
701
|
+
// const line = new Line( geometry, material );
|
|
702
|
+
// this.context.scene.add(line)
|
|
703
|
+
// }
|
|
704
|
+
getMaxAndMin(pos, dir) {
|
|
705
|
+
const box = new Box3().setFromObject(this);
|
|
706
|
+
const minOrigin = pos.clone().add(dir.clone().multiplyScalar(1e3));
|
|
707
|
+
const raycaster = new Ray(minOrigin, dir.clone().multiplyScalar(-1));
|
|
708
|
+
const min = new Vector32();
|
|
709
|
+
raycaster.intersectBox(box, min);
|
|
710
|
+
const maxOrigin = pos.clone().add(dir.clone().multiplyScalar(-1e3));
|
|
711
|
+
const raycaster2 = new Ray(maxOrigin, dir.clone());
|
|
712
|
+
const max = new Vector32();
|
|
713
|
+
raycaster2.intersectBox(box, max);
|
|
714
|
+
return {
|
|
715
|
+
max,
|
|
716
|
+
min
|
|
717
|
+
};
|
|
718
|
+
}
|
|
688
719
|
initGradualMaterial() {
|
|
689
720
|
const { max, min } = new Box3().setFromObject(this);
|
|
690
721
|
const _max = max.clone().sub(min);
|
|
691
722
|
const maxValue = Math.max(_max.x, _max.y, _max.z) / 2;
|
|
723
|
+
const pos = this.getPosition();
|
|
724
|
+
const dir = new Vector32(-1, 0.2, 0).normalize();
|
|
725
|
+
const { max: __max, min: _min } = this.getMaxAndMin(pos, dir);
|
|
692
726
|
const material = this.context.materialFactory.createShaderMaterial({
|
|
693
727
|
gradualColor: this.options.gradualColor,
|
|
694
728
|
center: this.getPosition(),
|
|
695
729
|
maxValue,
|
|
696
730
|
opacity: this.options.fillOpacity,
|
|
697
731
|
direction: new Vector32(-1, 0.2, 0),
|
|
698
|
-
max,
|
|
699
|
-
min
|
|
732
|
+
max: __max,
|
|
733
|
+
min: _min
|
|
700
734
|
});
|
|
701
735
|
if (this.options.height <= 0.1) {
|
|
702
736
|
this.material = material;
|
|
703
737
|
return material;
|
|
704
738
|
}
|
|
739
|
+
const center2 = this.getCenter();
|
|
740
|
+
const dir2 = new Vector32(-1, 0.2, 1).normalize();
|
|
741
|
+
const { max: ___max, min: __min } = this.getMaxAndMin(center2, dir2);
|
|
705
742
|
const material1 = this.context.materialFactory.createShaderMaterial({
|
|
706
743
|
gradualColor: [darkenColor(this.options.gradualColor[0], this.options.colorFactor), darkenColor(this.options.gradualColor[1], this.options.colorFactor)],
|
|
707
744
|
center: this.getCenter(),
|
|
708
745
|
maxValue,
|
|
709
746
|
opacity: this.options.fillOpacity,
|
|
710
747
|
direction: new Vector32(-1, 0.2, 1),
|
|
711
|
-
max,
|
|
712
|
-
min
|
|
748
|
+
max: ___max,
|
|
749
|
+
min: __min
|
|
713
750
|
});
|
|
714
751
|
this.material = [material, material1];
|
|
715
752
|
return [material, material1];
|
|
@@ -2442,7 +2479,14 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2442
2479
|
};
|
|
2443
2480
|
|
|
2444
2481
|
// src/factory/material.ts
|
|
2445
|
-
import {
|
|
2482
|
+
import {
|
|
2483
|
+
Color as Color4,
|
|
2484
|
+
LineBasicMaterial as LineBasicMaterial2,
|
|
2485
|
+
MeshStandardMaterial as MeshStandardMaterial2,
|
|
2486
|
+
MeshBasicMaterial as MeshBasicMaterial3,
|
|
2487
|
+
ShaderMaterial as ShaderMaterial2,
|
|
2488
|
+
DoubleSide as DoubleSide4
|
|
2489
|
+
} from "three";
|
|
2446
2490
|
function vectorToString(vector) {
|
|
2447
2491
|
return `${vector.x}-${vector.y}-${vector.z}`;
|
|
2448
2492
|
}
|
|
@@ -2499,8 +2543,18 @@ var MaterialFactory = class {
|
|
|
2499
2543
|
this.meshBasicMaterialMap.set(key, material);
|
|
2500
2544
|
return material;
|
|
2501
2545
|
}
|
|
2502
|
-
createShaderMaterial({
|
|
2503
|
-
|
|
2546
|
+
createShaderMaterial({
|
|
2547
|
+
gradualColor,
|
|
2548
|
+
center: center2,
|
|
2549
|
+
maxValue,
|
|
2550
|
+
opacity,
|
|
2551
|
+
direction,
|
|
2552
|
+
max,
|
|
2553
|
+
min
|
|
2554
|
+
}) {
|
|
2555
|
+
const key = `${gradualColor.toString()}-${vectorToString(
|
|
2556
|
+
center2
|
|
2557
|
+
)}-${maxValue}-${opacity}-${vectorToString(direction)}`;
|
|
2504
2558
|
if (this.shaderMaterialMap.has(key)) {
|
|
2505
2559
|
return this.shaderMaterialMap.get(key);
|
|
2506
2560
|
}
|
|
@@ -2515,11 +2569,23 @@ var MaterialFactory = class {
|
|
|
2515
2569
|
varying vec3 vColor;
|
|
2516
2570
|
|
|
2517
2571
|
void main() {
|
|
2572
|
+
vec3 lineVec = uMax - uMin; // \u7EBF\u6BB5AB\u7684\u65B9\u5411\u5411\u91CF
|
|
2573
|
+
vec3 AP = position - uMin; // \u5411\u91CFAP
|
|
2574
|
+
float t = dot(AP, lineVec) / dot(lineVec, lineVec); // \u53C2\u6570t
|
|
2575
|
+
t = clamp(t, 0.0, 1.0); // \u9650\u5236t\u5728[0, 1]\u8303\u56F4\u5185\uFF0C\u786E\u4FDD\u6700\u77ED\u8DDD\u79BB\u5728\u7EBF\u6BB5AB\u4E0A
|
|
2576
|
+
|
|
2577
|
+
vec3 closestPoint = uMin + t * lineVec; // \u6700\u77ED\u8DDD\u79BB\u70B9\u7684\u4F4D\u7F6E
|
|
2578
|
+
vec3 vecAP = closestPoint - uMin; // \u5411\u91CFAP'
|
|
2579
|
+
float distance = length(vecAP);
|
|
2580
|
+
float maxLen = length(lineVec);
|
|
2581
|
+
|
|
2518
2582
|
vec3 direction = normalize(uDirection);
|
|
2583
|
+
float gradient = dot(normalize(normal), normalize(uDirection));
|
|
2519
2584
|
vec3 currentPosition = position - center;
|
|
2520
|
-
float colorFactor = (dot(direction, currentPosition) / maxValue) * 0.5 + 0.5;
|
|
2585
|
+
// float colorFactor = (dot(direction, currentPosition) / maxValue) * 0.5 + 0.5;
|
|
2586
|
+
float colorFactor = distance / maxLen;
|
|
2521
2587
|
|
|
2522
|
-
vColor = mix(uColor, uGradualColor,
|
|
2588
|
+
vColor = mix(uColor, uGradualColor, 1.0 - t);
|
|
2523
2589
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
2524
2590
|
}
|
|
2525
2591
|
`;
|