@anov/3d-ability 0.0.4-alpha4 → 0.0.4-alpha6

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.
@@ -0,0 +1,8 @@
1
+ declare class Snow {
2
+ private meshes;
3
+ constructor();
4
+ private initGeometry;
5
+ stop(): void;
6
+ continue(): void;
7
+ }
8
+ export default Snow;
@@ -0,0 +1,2 @@
1
+ declare const createSkyCloud: (opacity?: number, density?: number) => [(density?: number) => void, () => void];
2
+ export default createSkyCloud;
@@ -0,0 +1,8 @@
1
+ declare class Snow {
2
+ private meshes;
3
+ constructor();
4
+ private initGeometry;
5
+ stop(): void;
6
+ continue(): void;
7
+ }
8
+ export default Snow;
@@ -0,0 +1,12 @@
1
+ import { Group, Vector3 } from '@anov/3d-core';
2
+ /**
3
+ * create sky system
4
+ * @param date
5
+ * @param latitude
6
+ * @param longitude
7
+ * @returns
8
+ */
9
+ declare const createSkySystem: (date: Date, latitude: number, longitude: number, sunRadius?: number) => [(currentDate?: Date) => Vector3, Group & {
10
+ sunPosition: Vector3;
11
+ }, any];
12
+ export default createSkySystem;
@@ -24,7 +24,7 @@ var initsSkySystem = function initsSkySystem(options) {
24
24
  mieDirectionalG: 0.7,
25
25
  elevation: 2,
26
26
  azimuth: 180,
27
- exposure: renderer.toneMappingExposure
27
+ exposure: 0.1
28
28
  };
29
29
  // @ts-ignore
30
30
  var uniforms = sky.material.uniforms;
@@ -48,15 +48,17 @@ var initSunLight = function initSunLight(options) {
48
48
  var opts = options || {};
49
49
  var sunLight = new DirectionalLight(getLastValue(opts.color, 'white'), getLastValue(opts.intensity, 1));
50
50
  sunLight.castShadow = true;
51
- sunLight.shadow.bias = getLastValue(opts.bias, -0.005);
52
- sunLight.shadow.mapSize.set(getLastValue((_opts$mapSize = opts.mapSize) === null || _opts$mapSize === void 0 ? void 0 : _opts$mapSize[0], 1024 * 2), getLastValue((_opts$mapSize2 = opts.mapSize) === null || _opts$mapSize2 === void 0 ? void 0 : _opts$mapSize2[1], 1024 * 2));
53
- var cam = sunLight.shadow.camera;
54
- // cam.near = getLastValue(opts.near, 0.1)
55
- // cam.far = getLastValue(opts.far, 10000)
56
- // cam.left = getLastValue(opts.left, -10000)
57
- // cam.right = getLastValue(opts.right, 10000)
58
- // cam.top = getLastValue(opts.top, 10000)
59
- // cam.bottom = getLastValue(opts.bottom, -10000)
51
+
52
+ // sunLight.shadow.bias = getLastValue(opts.bias, -0.005)
53
+ sunLight.shadow.mapSize.set(getLastValue((_opts$mapSize = opts.mapSize) === null || _opts$mapSize === void 0 ? void 0 : _opts$mapSize[0], 1024 * 10), getLastValue((_opts$mapSize2 = opts.mapSize) === null || _opts$mapSize2 === void 0 ? void 0 : _opts$mapSize2[1], 1024 * 10));
54
+
55
+ // const cam = sunLight.shadow.camera
56
+ // cam.near = getLastValue(opts.near, 0.1)
57
+ // cam.far = getLastValue(opts.far, 100000)
58
+ // cam.left = getLastValue(opts.left, -100000)
59
+ // cam.right = getLastValue(opts.right, 100000)
60
+ // cam.top = getLastValue(opts.top, 100000)
61
+ // cam.bottom = getLastValue(opts.bottom, -100000)
60
62
 
61
63
  return sunLight;
62
64
  };
@@ -73,6 +75,7 @@ var createSkySystem = function createSkySystem(date, latitude, longitude) {
73
75
  var _use$useScene2 = use.useScene(),
74
76
  renderer = _use$useScene2.renderer,
75
77
  scene = _use$useScene2.scene;
78
+ sunRadius = 300;
76
79
  if (!renderer && !scene) throw new Error('renderer or scene is not exist');
77
80
  var _initsSkySystem = initsSkySystem(),
78
81
  _initsSkySystem2 = _slicedToArray(_initsSkySystem, 3),
@@ -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","toneMappingExposure","uniforms","material","value","phi","degToRad","theta","setFromSphericalCoords","sunPosition","copy","initSunLight","opts","sunLight","color","intensity","castShadow","shadow","bias","mapSize","set","cam","camera","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: renderer!.toneMappingExposure,\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, 1))\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, 0.1)\n // cam.far = getLastValue(opts.far, 10000)\n // cam.left = getLastValue(opts.left, -10000)\n // cam.right = getLastValue(opts.right, 10000)\n // cam.top = getLastValue(opts.top, 10000)\n // cam.bottom = getLastValue(opts.bottom, -10000)\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 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 return [setDate, skyGroup, sky] as [typeof setDate, Group & { sunPosition: Vector3 }, any]\n}\n\nexport default createSkySystem\n"],"mappings":";;;;;;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AAQ,CAAC1C,QAAQ,CAACsB,IAAI,CAACtB,QAAQ,CAAC;IAEhC,OAAOqB,WAAW;EACpB,CAAC;EAED,sBAA8B1B,cAAc,CAACyC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,CAAC;IAA/DO,QAAQ,mBAARA,QAAQ;IAAElC,OAAO,mBAAPA,OAAO;EACzBiC,IAAI,CAACC,QAAQ,EAAElC,OAAO,CAAC;;EAEvB;AACF;AACA;AACA;AACA;EACE,IAAM0C,OAAO,GAAG,SAAVA,OAAO,CAAIC,WAAkB,EAAK;IACtC,uBAA8B3D,cAAc,CAAC2D,WAAW,IAAIlB,IAAI,EAAEC,QAAQ,EAAEC,SAAS,CAAC;MAA9EO,QAAQ,oBAARA,QAAQ;MAAElC,OAAO,oBAAPA,OAAO;IACzB,OAAOiC,IAAI,CAACC,QAAQ,EAAElC,OAAO,CAAC;EAChC,CAAC;EAED,OAAO,CAAC0C,OAAO,EAAEX,QAAQ,EAAE3C,GAAG,CAAC;AACjC,CAAC;AAED,eAAeoC,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","mapSize","set","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, 1))\n sunLight.castShadow = true\n\n // sunLight.shadow.bias = getLastValue(opts.bias, -0.005)\n sunLight.shadow.mapSize.set(getLastValue(opts.mapSize?.[0], 1024 * 10), getLastValue(opts.mapSize?.[1], 1024 * 10))\n\n // const cam = sunLight.shadow.camera\n // cam.near = getLastValue(opts.near, 0.1)\n // cam.far = getLastValue(opts.far, 100000)\n // cam.left = getLastValue(opts.left, -100000)\n // cam.right = getLastValue(opts.right, 100000)\n // cam.top = getLastValue(opts.top, 100000)\n // cam.bottom = getLastValue(opts.bottom, -100000)\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 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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,CAACC,QAAQ,EAAE9B,OAAO,CAAC;EAChC,CAAC;EAED,OAAO,CAACsC,OAAO,EAAEX,QAAQ,EAAEvC,GAAG,CAAC;AACjC,CAAC;AAED,eAAegC,eAAe"}
@@ -0,0 +1,16 @@
1
+ import type { SpeedType } from './rain';
2
+ declare type CreateSnowReturn = [
3
+ () => void,
4
+ () => void
5
+ ];
6
+ /**
7
+ * create snow
8
+ * @param size 雪花大小
9
+ * @param range 降雪范围
10
+ * @param speed 降雪速度
11
+ * @param opacity 雪花透明度
12
+ * @param count 雪花密度
13
+ * @returns
14
+ */
15
+ export declare const createSnow: (size?: number, range?: number, speed?: SpeedType, opacity?: number, count?: number) => CreateSnowReturn;
16
+ export {};
@@ -0,0 +1,26 @@
1
+ import { BufferGeometry, Points, PointsMaterial, Vector3 } from '@anov/3d-core';
2
+ import type { SpeedType } from '../rain';
3
+ interface EnvPointsOptions {
4
+ range?: number;
5
+ count?: number;
6
+ opacity?: number;
7
+ url: string;
8
+ size?: number;
9
+ speed?: SpeedType;
10
+ }
11
+ export declare type AVector3 = Vector3 & {
12
+ speedX: number;
13
+ speedY: number;
14
+ speedZ: number;
15
+ };
16
+ declare class EnvironmentPoints {
17
+ private opts;
18
+ points: AVector3[];
19
+ material: PointsMaterial | null;
20
+ geometry: BufferGeometry | null;
21
+ point: Points | null;
22
+ constructor(opts: EnvPointsOptions);
23
+ private createEnvPoints;
24
+ animation(handlefn: (position: AVector3) => void): void;
25
+ }
26
+ export default EnvironmentPoints;
@@ -34,8 +34,8 @@ var EnvironmentPoints = /*#__PURE__*/function () {
34
34
  var _this$opts$speed, _this$opts$speed2, _this$opts$speed3;
35
35
  var _position = new Vector3(Math.random() * range - range / 2, Math.random() * range, Math.random() * range - range / 2);
36
36
  _position.speedX = ((_this$opts$speed = this.opts.speed) === null || _this$opts$speed === void 0 ? void 0 : _this$opts$speed.x) || 0;
37
- _position.speedY = ((_this$opts$speed2 = this.opts.speed) === null || _this$opts$speed2 === void 0 ? void 0 : _this$opts$speed2.x) || 10;
38
- _position.speedZ = ((_this$opts$speed3 = this.opts.speed) === null || _this$opts$speed3 === void 0 ? void 0 : _this$opts$speed3.x) || 0;
37
+ _position.speedY = ((_this$opts$speed2 = this.opts.speed) === null || _this$opts$speed2 === void 0 ? void 0 : _this$opts$speed2.y) || 10;
38
+ _position.speedZ = ((_this$opts$speed3 = this.opts.speed) === null || _this$opts$speed3 === void 0 ? void 0 : _this$opts$speed3.z) || 0;
39
39
  this.points.push(_position);
40
40
  }
41
41
  this.geometry.setFromPoints(this.points);
@@ -1 +1 @@
1
- {"version":3,"names":["BufferGeometry","Points","PointsMaterial","TextureLoader","Vector3","EnvironmentPoints","opts","createEnvPoints","material","size","map","load","url","transparent","opacity","depthTest","geometry","range","i","count","position","Math","random","speedX","speed","x","speedY","speedZ","points","push","setFromPoints","point","handlefn","forEach"],"sources":["../../../src/environment/utils/points.ts"],"sourcesContent":["import { BufferGeometry, Points, PointsMaterial, TextureLoader, Vector3 } from '@anov/3d-core'\nimport type { SpeedType } from '../rain'\n\ninterface EnvPointsOptions {\n range?: number\n count?: number\n opacity?: number\n url: string\n size?: number\n speed?: SpeedType\n}\n\nexport type AVector3 = Vector3 & {\n speedX: number\n speedY: number\n speedZ: number\n}\n\nclass EnvironmentPoints {\n private opts: EnvPointsOptions = {} as EnvPointsOptions\n public points: AVector3[] = []\n\n public material: PointsMaterial | null = null\n public geometry: BufferGeometry | null = null\n public point: Points | null = null\n\n constructor(opts: EnvPointsOptions) {\n this.opts = opts\n\n this.createEnvPoints()\n }\n\n private createEnvPoints() {\n this.material = new PointsMaterial({\n size: this.opts.size || 1,\n map: new TextureLoader().load(this.opts.url),\n transparent: true,\n opacity: this.opts.opacity,\n depthTest: false,\n })\n\n this.geometry = new BufferGeometry()\n\n const range = this.opts.range ?? 1000\n\n for (let i = 0; i < (this.opts.count || 500); i++) {\n const position = new Vector3(\n Math.random() * range - range / 2,\n Math.random() * range,\n Math.random() * range - range / 2,\n ) as AVector3\n\n position.speedX = this.opts.speed?.x || 0\n position.speedY = this.opts.speed?.x || 10\n position.speedZ = this.opts.speed?.x || 0\n\n this.points.push(position)\n }\n this.geometry.setFromPoints(this.points)\n\n this.point = new Points(this.geometry, this.material)\n }\n\n public animation(handlefn: (position: AVector3) => void) {\n this.points.forEach((position) => {\n handlefn(position)\n })\n\n this.point!.geometry.setFromPoints(this.points)\n }\n}\n\nexport default EnvironmentPoints"],"mappings":";;;;;;;AAAA,SAASA,cAAc,EAAEC,MAAM,EAAEC,cAAc,EAAEC,aAAa,EAAEC,OAAO,QAAQ,eAAe;AAAA,IAkBxFC,iBAAiB;EAQrB,2BAAYC,IAAsB,EAAE;IAAA;IAAA,8BAPH,CAAC,CAAC;IAAA,gCACP,EAAE;IAAA,kCAEW,IAAI;IAAA,kCACJ,IAAI;IAAA,+BACf,IAAI;IAGhC,IAAI,CAACA,IAAI,GAAGA,IAAI;IAEhB,IAAI,CAACC,eAAe,EAAE;EACxB;EAAC;IAAA;IAAA,OAED,2BAA0B;MAAA;MACxB,IAAI,CAACC,QAAQ,GAAG,IAAIN,cAAc,CAAC;QACjCO,IAAI,EAAE,IAAI,CAACH,IAAI,CAACG,IAAI,IAAI,CAAC;QACzBC,GAAG,EAAE,IAAIP,aAAa,EAAE,CAACQ,IAAI,CAAC,IAAI,CAACL,IAAI,CAACM,GAAG,CAAC;QAC5CC,WAAW,EAAE,IAAI;QACjBC,OAAO,EAAE,IAAI,CAACR,IAAI,CAACQ,OAAO;QAC1BC,SAAS,EAAE;MACb,CAAC,CAAC;MAEF,IAAI,CAACC,QAAQ,GAAG,IAAIhB,cAAc,EAAE;MAEpC,IAAMiB,KAAK,uBAAG,IAAI,CAACX,IAAI,CAACW,KAAK,+DAAI,IAAI;MAErC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,IAAI,IAAI,CAACZ,IAAI,CAACa,KAAK,IAAI,GAAG,CAAC,EAAED,CAAC,EAAE,EAAE;QAAA;QACjD,IAAME,SAAQ,GAAG,IAAIhB,OAAO,CAC1BiB,IAAI,CAACC,MAAM,EAAE,GAAGL,KAAK,GAAGA,KAAK,GAAG,CAAC,EACjCI,IAAI,CAACC,MAAM,EAAE,GAAGL,KAAK,EACrBI,IAAI,CAACC,MAAM,EAAE,GAAGL,KAAK,GAAGA,KAAK,GAAG,CAAC,CACtB;QAEbG,SAAQ,CAACG,MAAM,GAAG,yBAAI,CAACjB,IAAI,CAACkB,KAAK,qDAAf,iBAAiBC,CAAC,KAAI,CAAC;QACzCL,SAAQ,CAACM,MAAM,GAAG,0BAAI,CAACpB,IAAI,CAACkB,KAAK,sDAAf,kBAAiBC,CAAC,KAAI,EAAE;QAC1CL,SAAQ,CAACO,MAAM,GAAG,0BAAI,CAACrB,IAAI,CAACkB,KAAK,sDAAf,kBAAiBC,CAAC,KAAI,CAAC;QAEzC,IAAI,CAACG,MAAM,CAACC,IAAI,CAACT,SAAQ,CAAC;MAC5B;MACA,IAAI,CAACJ,QAAQ,CAACc,aAAa,CAAC,IAAI,CAACF,MAAM,CAAC;MAExC,IAAI,CAACG,KAAK,GAAG,IAAI9B,MAAM,CAAC,IAAI,CAACe,QAAQ,EAAE,IAAI,CAACR,QAAQ,CAAC;IACvD;EAAC;IAAA;IAAA,OAED,mBAAiBwB,QAAsC,EAAE;MACvD,IAAI,CAACJ,MAAM,CAACK,OAAO,CAAC,UAACb,QAAQ,EAAK;QAChCY,QAAQ,CAACZ,QAAQ,CAAC;MACpB,CAAC,CAAC;MAEF,IAAI,CAACW,KAAK,CAAEf,QAAQ,CAACc,aAAa,CAAC,IAAI,CAACF,MAAM,CAAC;IACjD;EAAC;EAAA;AAAA;AAGH,eAAevB,iBAAiB"}
1
+ {"version":3,"names":["BufferGeometry","Points","PointsMaterial","TextureLoader","Vector3","EnvironmentPoints","opts","createEnvPoints","material","size","map","load","url","transparent","opacity","depthTest","geometry","range","i","count","position","Math","random","speedX","speed","x","speedY","y","speedZ","z","points","push","setFromPoints","point","handlefn","forEach"],"sources":["../../../src/environment/utils/points.ts"],"sourcesContent":["import { BufferGeometry, Points, PointsMaterial, TextureLoader, Vector3 } from '@anov/3d-core'\nimport type { SpeedType } from '../rain'\n\ninterface EnvPointsOptions {\n range?: number\n count?: number\n opacity?: number\n url: string\n size?: number\n speed?: SpeedType\n}\n\nexport type AVector3 = Vector3 & {\n speedX: number\n speedY: number\n speedZ: number\n}\n\nclass EnvironmentPoints {\n private opts: EnvPointsOptions = {} as EnvPointsOptions\n public points: AVector3[] = []\n\n public material: PointsMaterial | null = null\n public geometry: BufferGeometry | null = null\n public point: Points | null = null\n\n constructor(opts: EnvPointsOptions) {\n this.opts = opts\n\n this.createEnvPoints()\n }\n\n private createEnvPoints() {\n this.material = new PointsMaterial({\n size: this.opts.size || 1,\n map: new TextureLoader().load(this.opts.url),\n transparent: true,\n opacity: this.opts.opacity,\n depthTest: false,\n })\n\n this.geometry = new BufferGeometry()\n\n const range = this.opts.range ?? 1000\n\n for (let i = 0; i < (this.opts.count || 500); i++) {\n const position = new Vector3(\n Math.random() * range - range / 2,\n Math.random() * range,\n Math.random() * range - range / 2,\n ) as AVector3\n\n position.speedX = this.opts.speed?.x || 0\n position.speedY = this.opts.speed?.y || 10\n position.speedZ = this.opts.speed?.z || 0\n\n this.points.push(position)\n }\n this.geometry.setFromPoints(this.points)\n\n this.point = new Points(this.geometry, this.material)\n }\n\n public animation(handlefn: (position: AVector3) => void) {\n this.points.forEach((position) => {\n handlefn(position)\n })\n\n this.point!.geometry.setFromPoints(this.points)\n }\n}\n\nexport default EnvironmentPoints"],"mappings":";;;;;;;AAAA,SAASA,cAAc,EAAEC,MAAM,EAAEC,cAAc,EAAEC,aAAa,EAAEC,OAAO,QAAQ,eAAe;AAAA,IAkBxFC,iBAAiB;EAQrB,2BAAYC,IAAsB,EAAE;IAAA;IAAA,8BAPH,CAAC,CAAC;IAAA,gCACP,EAAE;IAAA,kCAEW,IAAI;IAAA,kCACJ,IAAI;IAAA,+BACf,IAAI;IAGhC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IAAI,CAACC,MAAM,CAACC,IAAI,CAACX,SAAQ,CAAC;MAC5B;MACA,IAAI,CAACJ,QAAQ,CAACgB,aAAa,CAAC,IAAI,CAACF,MAAM,CAAC;MAExC,IAAI,CAACG,KAAK,GAAG,IAAIhC,MAAM,CAAC,IAAI,CAACe,QAAQ,EAAE,IAAI,CAACR,QAAQ,CAAC;IACvD;EAAC;IAAA;IAAA,OAED,mBAAiB0B,QAAsC,EAAE;MACvD,IAAI,CAACJ,MAAM,CAACK,OAAO,CAAC,UAACf,QAAQ,EAAK;QAChCc,QAAQ,CAACd,QAAQ,CAAC;MACpB,CAAC,CAAC;MAEF,IAAI,CAACa,KAAK,CAAEjB,QAAQ,CAACgB,aAAa,CAAC,IAAI,CAACF,MAAM,CAAC;IACjD;EAAC;EAAA;AAAA;AAGH,eAAezB,iBAAiB"}
@@ -1,2 +1,2 @@
1
- import type { IPOIOption } from './index';
1
+ import type { IPOIOption } from './type';
2
2
  export declare const getDom: (option: IPOIOption) => HTMLDivElement;
@@ -33,4 +33,4 @@ export var getDom = function getDom(option) {
33
33
  container.appendChild(poiDom);
34
34
  return container;
35
35
  };
36
- //# sourceMappingURL=poiDom.js.map
36
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IMG_BASE","IMG_LINE","style","common","color","boxSizing","padding","display","justifyContent","backgroundSize","backgroundRepeat","base","width","height","alignItems","backgroundImage","line","getDom","option","container","document","createElement","poiDom","type","forEach","item","Object","keys","key","innerText","title","appendChild"],"sources":["../../src/poi/dom.ts"],"sourcesContent":["import { IMG_BASE, IMG_LINE } from './assets'\nimport type { IPOIOption } from './type'\n\nconst style = {\n common: {\n color: '#fff',\n boxSizing: 'border-box',\n padding: '10px',\n display: 'flex',\n justifyContent: 'center',\n backgroundSize: '100% 100%',\n backgroundRepeat: 'no-repeat',\n },\n base: {\n width: '200px',\n height: '100px',\n alignItems: 'center',\n backgroundImage: `url(\"${IMG_BASE}\")`,\n },\n line: {\n width: '200px',\n height: '200px',\n backgroundImage: `url(\"${IMG_LINE}\")`,\n },\n}\n\nexport const getDom = (option: IPOIOption) => {\n const container = document.createElement('div')\n const poiDom = document.createElement('div');\n\n [style.common, style[option.type], option.style || {}].forEach((item) => {\n Object.keys(item).forEach((key) => {\n poiDom.style[key] = item[key]\n })\n })\n poiDom.innerText = option.title\n container.appendChild(poiDom)\n return container\n}"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,QAAQ;AAG3B,IAAMC,KAAK,GAAG;EACZC,MAAM,EAAE;IACNC,KAAK,EAAE,MAAM;IACbC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,MAAM;IACfC,OAAO,EAAE,MAAM;IACfC,cAAc,EAAE,QAAQ;IACxBC,cAAc,EAAE,WAAW;IAC3BC,gBAAgB,EAAE;EACpB,CAAC;EACDC,IAAI,EAAE;IACJC,KAAK,EAAE,OAAO;IACdC,MAAM,EAAE,OAAO;IACfC,UAAU,EAAE,QAAQ;IACpBC,eAAe,kBAAUf,QAAQ;EACnC,CAAC;EACDgB,IAAI,EAAE;IACJJ,KAAK,EAAE,OAAO;IACdC,MAAM,EAAE,OAAO;IACfE,eAAe,kBAAUd,QAAQ;EACnC;AACF,CAAC;AAED,OAAO,IAAMgB,MAAM,GAAG,SAATA,MAAM,CAAIC,MAAkB,EAAK;EAC5C,IAAMC,SAAS,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC/C,IAAMC,MAAM,GAAGF,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAE5C,CAACnB,KAAK,CAACC,MAAM,EAAED,KAAK,CAACgB,MAAM,CAACK,IAAI,CAAC,EAAEL,MAAM,CAAChB,KAAK,IAAI,CAAC,CAAC,CAAC,CAACsB,OAAO,CAAC,UAACC,IAAI,EAAK;IACvEC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACD,OAAO,CAAC,UAACI,GAAG,EAAK;MACjCN,MAAM,CAACpB,KAAK,CAAC0B,GAAG,CAAC,GAAGH,IAAI,CAACG,GAAG,CAAC;IAC/B,CAAC,CAAC;EACJ,CAAC,CAAC;EACFN,MAAM,CAACO,SAAS,GAAGX,MAAM,CAACY,KAAK;EAC/BX,SAAS,CAACY,WAAW,CAACT,MAAM,CAAC;EAC7B,OAAOH,SAAS;AAClB,CAAC"}
@@ -1,18 +1,4 @@
1
- export declare enum EPOIType {
2
- base = 0,
3
- line = 1
4
- }
5
- export interface IPOIOption {
6
- id?: number | string;
7
- name?: string;
8
- position?: Array<number>;
9
- location?: Array<number>;
10
- visible?: boolean;
11
- type?: EPOIType;
12
- title: string;
13
- autoSize?: boolean;
14
- style?: object;
15
- }
1
+ import type { IPOIOption } from './type';
16
2
  declare class Poi {
17
3
  private cssObjects;
18
4
  constructor();
@@ -22,6 +8,11 @@ declare class Poi {
22
8
  visible: boolean | undefined;
23
9
  position: number[] | undefined;
24
10
  };
11
+ /**
12
+ * 是否锁定镜头,标牌一直面向镜头
13
+ */
14
+ private updateAxis;
15
+ private updateScale;
25
16
  delete(option: IPOIOption): void;
26
17
  update(option: IPOIOption): void;
27
18
  }
package/dist/poi/index.js CHANGED
@@ -5,14 +5,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
7
  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); }
8
- import { create3DLabel, use } from '@anov/3d-core';
8
+ import { Vector3, create3DLabel, use } from '@anov/3d-core';
9
9
  import { getLastValue } from "../utils";
10
- import { getDom } from "./poiDom";
11
- export var EPOIType;
12
- (function (EPOIType) {
13
- EPOIType[EPOIType["base"] = 0] = "base";
14
- EPOIType[EPOIType["line"] = 1] = "line";
15
- })(EPOIType || (EPOIType = {}));
10
+ import { getDom } from "./dom";
11
+ // 距离限制范围的值,用于计算缩放比例
12
+ var minDistance = 0.1;
13
+ var maxDistance = 1000000;
16
14
  var Poi = /*#__PURE__*/function () {
17
15
  function Poi() {
18
16
  _classCallCheck(this, Poi);
@@ -22,6 +20,7 @@ var Poi = /*#__PURE__*/function () {
22
20
  _createClass(Poi, [{
23
21
  key: "create",
24
22
  value: function create(option) {
23
+ var _this = this;
25
24
  var visible = option.visible,
26
25
  position = option.position,
27
26
  name = option.name;
@@ -29,10 +28,11 @@ var Poi = /*#__PURE__*/function () {
29
28
  // 对象名称
30
29
  poiLabel.name = getLastValue(name, 'poiLabel');
31
30
  poiLabel.receiveShadow = true;
31
+ poiLabel.option = option;
32
32
  // 是否可见
33
33
  poiLabel.visible = getLastValue(visible, true);
34
34
  // 设置poi局部位置
35
- position && poiLabel.position.set(position[0], position[1], position[2]);
35
+ position && poiLabel.position.copy(new Vector3().fromArray(position));
36
36
  // poiLabel.position.set(0, (200 * 0.023) / 2 + 3, 0);
37
37
 
38
38
  var devicePixelRatio = window.devicePixelRatio || 1;
@@ -43,7 +43,10 @@ var Poi = /*#__PURE__*/function () {
43
43
  // 添加到场景
44
44
  scene === null || scene === void 0 ? void 0 : scene.add(poiLabel);
45
45
  this.cssObjects.push(poiLabel);
46
- use.useframe(function () {});
46
+ use.useframe(function () {
47
+ option.lockAxis && _this.updateAxis(poiLabel);
48
+ if ('autoSize' in option && !option.autoSize) _this.updateScale(poiLabel);
49
+ });
47
50
  return {
48
51
  id: poiLabel.id,
49
52
  name: name,
@@ -52,15 +55,51 @@ var Poi = /*#__PURE__*/function () {
52
55
  };
53
56
  }
54
57
 
58
+ /**
59
+ * 是否锁定镜头,标牌一直面向镜头
60
+ */
61
+ }, {
62
+ key: "updateAxis",
63
+ value: function updateAxis(object) {
64
+ var _use$useScene2 = use.useScene(),
65
+ camera = _use$useScene2.camera;
66
+ // 获取原有的旋转角度
67
+ var oriEuler = object.rotation;
68
+ // 根据锁定的轴进行旋转
69
+ camera && object.rotation.copy(camera.rotation);
70
+ }
71
+
72
+ /// <summary>
73
+ /// 按照距离缩放,距离越远,缩放越大
74
+ /// </summary>
75
+ }, {
76
+ key: "updateScale",
77
+ value: function updateScale(object) {
78
+ var _use$useScene3 = use.useScene(),
79
+ camera = _use$useScene3.camera;
80
+ // 获取相机和物体的世界坐标位置
81
+ var cameraPosition = camera === null || camera === void 0 ? void 0 : camera.position;
82
+ var objectPosition = object.position;
83
+
84
+ // 计算相机和物体之间的距离
85
+ var distance = (cameraPosition === null || cameraPosition === void 0 ? void 0 : cameraPosition.distanceTo(objectPosition)) || 0.1;
86
+
87
+ // 使用 Math.min() 和 Math.max() 方法限制 resultDistance 的范围
88
+ var clampedDistance = Math.max(minDistance, Math.min(maxDistance, distance));
89
+
90
+ // 按照缩放系数和距离进行缩放,缩放系数应该约定好一个固定值
91
+ object.scale.copy(new Vector3(1, 1, 1).multiplyScalar(clampedDistance * 0.0012));
92
+ }
93
+
55
94
  // 删除POI点信息
56
95
  }, {
57
96
  key: "delete",
58
97
  value: function _delete(option) {
59
- var _use$useScene2 = use.useScene(),
60
- scene = _use$useScene2.scene;
98
+ var _use$useScene4 = use.useScene(),
99
+ scene = _use$useScene4.scene;
61
100
  for (var i = 0; i < this.cssObjects.length; i++) {
62
101
  if (this.cssObjects[i].id === option.id) {
63
- scene.remove(this.cssObjects[i]);
102
+ scene === null || scene === void 0 ? void 0 : scene.remove(this.cssObjects[i]);
64
103
  break;
65
104
  }
66
105
  }
@@ -1 +1 @@
1
- {"version":3,"names":["create3DLabel","use","getLastValue","getDom","EPOIType","Poi","option","visible","position","name","poiLabel","receiveShadow","set","devicePixelRatio","window","scale","useScene","scene","add","cssObjects","push","useframe","id","i","length","remove"],"sources":["../../src/poi/index.ts"],"sourcesContent":["import type {\n CSS2DObject,\n CSS3DObject,\n} from '@anov/3d-core'\nimport {\n create3DLabel,\n createLabel,\n use,\n} from '@anov/3d-core'\nimport { getLastValue } from '../utils'\nimport { getDom } from './poiDom'\n\nexport enum EPOIType {\n base,\n line,\n}\n\nexport interface IPOIOption {\n id?: number | string // 唯一ID\n name?: string // 别名\n position?: Array<number> // 聚焦目标位置[x,y,z] 单位cm positon和location字段必须有一个非空\n location?: Array<number> // 聚焦目标位置[经度,纬度,高度] 单位m positon和location字段必须有一个非空\n visible?: boolean // POI创建后是否可见\n type?: EPOIType\n title: string\n autoSize?: boolean // css2D渲染或3D渲染\n style?: object // POI样式字符串\n}\n\ntype CSSObject = CSS2DObject | CSS3DObject\n\nclass Poi {\n private cssObjects: CSSObject[] = []\n\n constructor() { }\n // 添加POI点信息\n public create(option: IPOIOption) {\n const { visible, position, name } = option\n\n const poiLabel = create3DLabel(getDom(option))\n // 对象名称\n poiLabel.name = getLastValue(name, 'poiLabel')\n poiLabel.receiveShadow = true\n // 是否可见\n poiLabel.visible = getLastValue(visible, true)\n // 设置poi局部位置\n position && poiLabel.position.set(position[0], position[1], position[2])\n // poiLabel.position.set(0, (200 * 0.023) / 2 + 3, 0);\n\n const devicePixelRatio = window.devicePixelRatio || 1\n // 调整场景中对象的缩放比例\n poiLabel.scale.set(0.023, 0.023, 0.023)\n\n const { scene } = use.useScene()\n // 添加到场景\n scene?.add(poiLabel)\n this.cssObjects.push(poiLabel)\n\n use.useframe(() => {\n })\n\n return {\n id: poiLabel.id,\n name,\n visible,\n position,\n }\n }\n\n // 删除POI点信息\n public delete(option: IPOIOption) {\n const { scene } = use.useScene()\n for (let i = 0; i < this.cssObjects.length; i++) {\n if (this.cssObjects[i].id === option.id) {\n scene.remove(this.cssObjects[i])\n break\n }\n }\n }\n\n public update(option: IPOIOption) { }\n}\n\nexport default Poi\n"],"mappings":";;;;;;;AAIA,SACEA,aAAa,EAEbC,GAA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,CAAC,YAAM,CACnB,CAAC,CAAC;MAEF,OAAO;QACLC,EAAE,EAAEZ,QAAQ,CAACY,EAAE;QACfb,IAAI,EAAJA,IAAI;QACJF,OAAO,EAAPA,OAAO;QACPC,QAAQ,EAARA;MACF,CAAC;IACH;;IAEA;EAAA;IAAA;IAAA,OACA,iBAAcF,MAAkB,EAAE;MAChC,qBAAkBL,GAAG,CAACe,QAAQ,EAAE;QAAxBC,KAAK,kBAALA,KAAK;MACb,KAAK,IAAIM,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,CAACJ,UAAU,CAACK,MAAM,EAAED,CAAC,EAAE,EAAE;QAC/C,IAAI,IAAI,CAACJ,UAAU,CAACI,CAAC,CAAC,CAACD,EAAE,KAAKhB,MAAM,CAACgB,EAAE,EAAE;UACvCL,KAAK,CAACQ,MAAM,CAAC,IAAI,CAACN,UAAU,CAACI,CAAC,CAAC,CAAC;UAChC;QACF;MACF;IACF;EAAC;IAAA;IAAA,OAED,gBAAcjB,MAAkB,EAAE,CAAE;EAAC;EAAA;AAAA;AAGvC,eAAeD,GAAG"}
1
+ {"version":3,"names":["Vector3","create3DLabel","use","getLastValue","getDom","minDistance","maxDistance","Poi","option","visible","position","name","poiLabel","receiveShadow","copy","fromArray","devicePixelRatio","window","scale","set","useScene","scene","add","cssObjects","push","useframe","lockAxis","updateAxis","autoSize","updateScale","id","object","camera","oriEuler","rotation","cameraPosition","objectPosition","distance","distanceTo","clampedDistance","Math","max","min","multiplyScalar","i","length","remove"],"sources":["../../src/poi/index.ts"],"sourcesContent":["import {\n Vector3,\n create3DLabel,\n use,\n} from '@anov/3d-core'\nimport { getLastValue } from '../utils'\nimport { getDom } from './dom'\nimport type { CustomCssObjec, IPOIOption } from './type'\n\n// 距离限制范围的值,用于计算缩放比例\nconst minDistance = 0.1\nconst maxDistance = 1000000\n\nclass Poi {\n private cssObjects: CustomCssObjec[] = []\n\n constructor() { }\n // 添加POI点信息\n public create(option: IPOIOption) {\n const { visible, position, name } = option\n\n const poiLabel = create3DLabel(getDom(option)) as CustomCssObjec\n // 对象名称\n poiLabel.name = getLastValue(name, 'poiLabel')\n poiLabel.receiveShadow = true\n poiLabel.option = option\n // 是否可见\n poiLabel.visible = getLastValue(visible, true)\n // 设置poi局部位置\n position && poiLabel.position.copy(new Vector3().fromArray(position))\n // poiLabel.position.set(0, (200 * 0.023) / 2 + 3, 0);\n\n const devicePixelRatio = window.devicePixelRatio || 1\n // 调整场景中对象的缩放比例\n poiLabel.scale.set(0.023, 0.023, 0.023)\n const { scene } = use.useScene()\n // 添加到场景\n scene?.add(poiLabel)\n this.cssObjects.push(poiLabel)\n\n use.useframe(() => {\n option.lockAxis && this.updateAxis(poiLabel)\n if ('autoSize' in option && !option.autoSize)\n this.updateScale(poiLabel)\n })\n\n return {\n id: poiLabel.id,\n name,\n visible,\n position,\n }\n }\n\n /**\n * 是否锁定镜头,标牌一直面向镜头\n */\n private updateAxis(object: CustomCssObjec) {\n const { camera } = use.useScene()\n // 获取原有的旋转角度\n const oriEuler = object.rotation\n // 根据锁定的轴进行旋转\n camera && object.rotation.copy(camera.rotation)\n }\n\n /// <summary>\n /// 按照距离缩放,距离越远,缩放越大\n /// </summary>\n private updateScale(object: CustomCssObjec) {\n const { camera } = use.useScene()\n // 获取相机和物体的世界坐标位置\n const cameraPosition = camera?.position\n const objectPosition = object.position\n\n // 计算相机和物体之间的距离\n const distance = cameraPosition?.distanceTo(objectPosition) || 0.1\n\n // 使用 Math.min() 和 Math.max() 方法限制 resultDistance 的范围\n const clampedDistance = Math.max(minDistance, Math.min(maxDistance, distance))\n\n // 按照缩放系数和距离进行缩放,缩放系数应该约定好一个固定值\n object.scale.copy(new Vector3(1, 1, 1).multiplyScalar(clampedDistance * 0.0012))\n }\n\n // 删除POI点信息\n public delete(option: IPOIOption) {\n const { scene } = use.useScene()\n for (let i = 0; i < this.cssObjects.length; i++) {\n if (this.cssObjects[i].id === option.id) {\n scene?.remove(this.cssObjects[i])\n break\n }\n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ACJ,IAAI,CAAC,IAAId,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC2C,cAAc,CAACJ,eAAe,GAAG,MAAM,CAAC,CAAC;IAClF;;IAEA;EAAA;IAAA;IAAA,OACA,iBAAc/B,MAAkB,EAAE;MAChC,qBAAkBN,GAAG,CAACkB,QAAQ,EAAE;QAAxBC,KAAK,kBAALA,KAAK;MACb,KAAK,IAAIuB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,CAACrB,UAAU,CAACsB,MAAM,EAAED,CAAC,EAAE,EAAE;QAC/C,IAAI,IAAI,CAACrB,UAAU,CAACqB,CAAC,CAAC,CAACd,EAAE,KAAKtB,MAAM,CAACsB,EAAE,EAAE;UACvCT,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEyB,MAAM,CAAC,IAAI,CAACvB,UAAU,CAACqB,CAAC,CAAC,CAAC;UACjC;QACF;MACF;IACF;EAAC;IAAA;IAAA,OAED,gBAAcpC,MAAkB,EAAE,CAAE;EAAC;EAAA;AAAA;AAGvC,eAAeD,GAAG"}
@@ -0,0 +1,20 @@
1
+ import type { CSS3DObject } from '@anov/3d-core';
2
+ export declare enum EPOIType {
3
+ base = 0,
4
+ line = 1
5
+ }
6
+ export interface CustomCssObjec extends CSS3DObject {
7
+ option: IPOIOption;
8
+ }
9
+ export interface IPOIOption {
10
+ id?: number | string;
11
+ name?: string;
12
+ title: string;
13
+ type?: EPOIType;
14
+ position?: Array<number>;
15
+ location?: Array<number>;
16
+ visible?: boolean;
17
+ autoSize?: boolean;
18
+ lockAxis?: Boolean;
19
+ style?: object;
20
+ }
@@ -0,0 +1,6 @@
1
+ export var EPOIType;
2
+ (function (EPOIType) {
3
+ EPOIType[EPOIType["base"] = 0] = "base";
4
+ EPOIType[EPOIType["line"] = 1] = "line";
5
+ })(EPOIType || (EPOIType = {}));
6
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EPOIType"],"sources":["../../src/poi/type.ts"],"sourcesContent":["import type {\n CSS3DObject,\n} from '@anov/3d-core'\n\nexport enum EPOIType {\n base,\n line,\n}\n\nexport interface CustomCssObjec extends CSS3DObject {\n option: IPOIOption\n}\n\nexport interface IPOIOption {\n id?: number | string // 唯一ID\n name?: string // 别名\n title: string\n type?: EPOIType\n position?: Array<number> // 聚焦目标位置[x,y,z] 单位cm positon和location字段必须有一个非空\n location?: Array<number> // 聚焦目标位置[经度,纬度,高度] 单位m positon和location字段必须有一个非空\n visible?: boolean\n autoSize?: boolean // 是否支持缩放\n lockAxis?: Boolean // 是否锁定镜头(标牌一直面向镜头)\n style?: object // POI样式字符串\n}\n"],"mappings":"AAIA,WAAYA,QAAQ;AAGnB,WAHWA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;AAAA,GAARA,QAAQ,KAARA,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anov/3d-ability",
3
- "version": "0.0.4-alpha4",
3
+ "version": "0.0.4-alpha6",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "@types/suncalc": "^1.9.2",
20
20
  "postprocessing": "^6.33.3",
21
21
  "suncalc": "^1.9.0",
22
- "@anov/3d-core": "^0.0.4-alpha14"
22
+ "@anov/3d-core": "^0.0.4-alpha17"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "father build",
@@ -1 +0,0 @@
1
- {"version":3,"names":["IMG_BASE","IMG_LINE","style","common","color","boxSizing","padding","display","justifyContent","backgroundSize","backgroundRepeat","base","width","height","alignItems","backgroundImage","line","getDom","option","container","document","createElement","poiDom","type","forEach","item","Object","keys","key","innerText","title","appendChild"],"sources":["../../src/poi/poiDom.ts"],"sourcesContent":["import { IMG_BASE, IMG_LINE } from './assets'\nimport type { IPOIOption } from './index'\nimport { EPOIType } from './index'\n\nconst style = {\n common: {\n color: '#fff',\n boxSizing: 'border-box',\n padding: '10px',\n display: 'flex',\n justifyContent: 'center',\n backgroundSize: '100% 100%',\n backgroundRepeat: 'no-repeat',\n },\n base: {\n width: '200px',\n height: '100px',\n alignItems: 'center',\n backgroundImage: `url(\"${IMG_BASE}\")`,\n },\n line: {\n width: '200px',\n height: '200px',\n backgroundImage: `url(\"${IMG_LINE}\")`,\n },\n}\n\nexport const getDom = (option: IPOIOption) => {\n const container = document.createElement('div')\n const poiDom = document.createElement('div');\n\n [style.common, style[option.type], option.style || {}].forEach((item) => {\n Object.keys(item).forEach((key) => {\n poiDom.style[key] = item[key]\n })\n })\n poiDom.innerText = option.title\n container.appendChild(poiDom)\n return container\n}"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,QAAQ;AAI3B,IAAMC,KAAK,GAAG;EACZC,MAAM,EAAE;IACNC,KAAK,EAAE,MAAM;IACbC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,MAAM;IACfC,OAAO,EAAE,MAAM;IACfC,cAAc,EAAE,QAAQ;IACxBC,cAAc,EAAE,WAAW;IAC3BC,gBAAgB,EAAE;EACpB,CAAC;EACDC,IAAI,EAAE;IACJC,KAAK,EAAE,OAAO;IACdC,MAAM,EAAE,OAAO;IACfC,UAAU,EAAE,QAAQ;IACpBC,eAAe,kBAAUf,QAAQ;EACnC,CAAC;EACDgB,IAAI,EAAE;IACJJ,KAAK,EAAE,OAAO;IACdC,MAAM,EAAE,OAAO;IACfE,eAAe,kBAAUd,QAAQ;EACnC;AACF,CAAC;AAED,OAAO,IAAMgB,MAAM,GAAG,SAATA,MAAM,CAAIC,MAAkB,EAAK;EAC5C,IAAMC,SAAS,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC/C,IAAMC,MAAM,GAAGF,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAE5C,CAACnB,KAAK,CAACC,MAAM,EAAED,KAAK,CAACgB,MAAM,CAACK,IAAI,CAAC,EAAEL,MAAM,CAAChB,KAAK,IA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