@anov/3d-ability 0.0.24 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/camera/index.js +0 -1
- package/dist/camera/index.js.map +1 -1
- package/dist/common/IconStyle.d.ts +17 -0
- package/dist/common/IconStyle.js +41 -0
- package/dist/common/IconStyle.js.map +1 -0
- package/dist/common/ImageStyle.d.ts +15 -0
- package/dist/common/ImageStyle.js +37 -0
- package/dist/common/ImageStyle.js.map +1 -0
- package/dist/common/LabelStyle.d.ts +24 -0
- package/dist/common/LabelStyle.js +71 -0
- package/dist/common/LabelStyle.js.map +1 -0
- package/dist/common/component.d.ts +15 -0
- package/dist/common/component.js +70 -0
- package/dist/common/component.js.map +1 -0
- package/dist/common/constant.d.ts +5 -0
- package/dist/common/constant.js +7 -0
- package/dist/common/constant.js.map +1 -0
- package/dist/controls/base.d.ts +7 -0
- package/dist/controls/base.js +16 -0
- package/dist/controls/base.js.map +1 -0
- package/dist/controls/index.d.ts +2 -0
- package/dist/controls/index.js +3 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/src/FirstViewControl.d.ts +30 -0
- package/dist/controls/src/FirstViewControl.js +132 -0
- package/dist/controls/src/FirstViewControl.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/poi/2D/index.d.ts +1 -1
- package/dist/poi/2D/index.js +1 -1
- package/dist/poi/2D/index.js.map +1 -1
- package/dist/poi/3D/index.d.ts +1 -1
- package/dist/poi/3D/index.js +1 -1
- package/dist/poi/3D/index.js.map +1 -1
- package/dist/poi/Base.d.ts +12 -0
- package/dist/poi/Base.js +55 -0
- package/dist/poi/Base.js.map +1 -0
- package/dist/poi/Poi.d.ts +11 -10
- package/dist/poi/Poi.js +88 -26
- package/dist/poi/Poi.js.map +1 -1
- package/dist/poi/Sprite/index.d.ts +1 -1
- package/dist/poi/Sprite/index.js +1 -1
- package/dist/poi/Sprite/index.js.map +1 -1
- package/dist/poi/Sprite/index2.js.map +1 -1
- package/dist/poi/index.d.ts +2 -1
- package/dist/poi/index.js +2 -1
- package/dist/poi/index.js.map +1 -1
- package/dist/widget/icon.d.ts +14 -0
- package/dist/widget/icon.js +64 -0
- package/dist/widget/icon.js.map +1 -0
- package/dist/widget/image.d.ts +14 -0
- package/dist/widget/image.js +65 -0
- package/dist/widget/image.js.map +1 -0
- package/dist/widget/label.d.ts +14 -0
- package/dist/widget/label.js +70 -0
- package/dist/widget/label.js.map +1 -0
- package/dist/widget/poi.d.ts +0 -0
- package/dist/widget/poi.js +2 -0
- package/dist/widget/poi.js.map +1 -0
- package/package.json +3 -3
package/dist/camera/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var Camera = /*#__PURE__*/function () {
|
|
|
15
15
|
_defineProperty(this, "isTransitionPeriod", false);
|
|
16
16
|
_defineProperty(this, "isTrigger", true);
|
|
17
17
|
_defineProperty(this, "tween", void 0);
|
|
18
|
-
this.isTrigger = true;
|
|
19
18
|
this.camera = sceneControl.camera;
|
|
20
19
|
this.controls = sceneControl.controls;
|
|
21
20
|
this.sceneControl = sceneControl;
|
package/dist/camera/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Box3","MathUtils","TWEEN","Vector3","Camera","camera","controls","sceneControl","isTrigger","handleChanged","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","userInput","Array","isArray","caclCurrentPos","moveCameraTo","caclSingleCoordinate","fromArray","_","x","y","z","options","currentPoition","currentPositionInterpolation","copy","requestAnimationFrame","renderer","render","scene","tween","stop","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, SceneControl } from '@anov/3d-core'\nimport { Box3, MathUtils, TWEEN, Vector3 } from '@anov/3d-core'\n\ntype vector3Array = number[]\ninterface ChangeCameraPresetOptions {\n duration?: number\n onUpdate?: (params: { position: Vector3; lookat: Vector3 }) => void\n onStart?: () => void\n onComplate?: () => void\n isTrigger?: boolean\n}\n\nclass Camera {\n private camera: PerspectiveCamera\n private controls: OrbitControls\n private sceneControl: SceneControl\n private isTransitionPeriod = false\n private isTrigger = true\n private tween: any\n\n constructor(camera: PerspectiveCamera, controls: OrbitControls, sceneControl: SceneControl) {\n this.isTrigger = true\n this.camera = sceneControl.camera!\n this.controls = sceneControl.controls!\n this.sceneControl = sceneControl\n this.handleChanged()\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 * caclSingleCoordinate\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 * handle camera changed\n */\n private handleChanged() {\n // this.controls.addEventListener('change', () => {\n // // if (this.isTransitionPeriod)\n // // this.sceneControl.renderer!.render(this.sceneControl.scene!, this.sceneControl.camera!)\n // })\n }\n\n /**\n * focus On Position\n * @param params\n */\n focus(params: { target: vector3Array | vector3Array[]; pitch?: number; duration?: number; isTrigger?: boolean }) {\n return new Promise((res) => {\n const { target: position, pitch, duration } = params\n const moveOptions = () => ({\n duration: (duration && duration * 1000) ?? 1000,\n isTrigger: params.isTrigger ?? true,\n onUpdate: ({ position, lookat }) => {\n this.isTrigger = params.isTrigger ?? true\n },\n onComplate: () => {\n this.isTrigger = false\n\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\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 isTrigger: params.isTrigger ?? true,\n duration: (params.duration && params.duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n this.isTrigger = params.isTrigger ?? true\n },\n onComplate: () => {\n this.isTrigger = false\n\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.isTrigger = !options.isTrigger\n this.camera.position.copy(position)\n this.controls.target.copy(target)\n\n requestAnimationFrame(() => {\n options?.onComplate && options.onComplate()\n this.sceneControl.renderer!.render(this.sceneControl.scene!, this.sceneControl.camera!)\n })\n\n return\n }\n\n if (this.tween)\n this.tween.stop()\n\n this.tween = 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 requestAnimationFrame(() => {\n options?.onComplate && options.onComplate()\n })\n\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,IAWzDC,MAAM;EAQV,gBAAYC,MAAyB,EAAEC,QAAuB,EAAEC,YAA0B,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA,4CAJ/D,KAAK;IAAA,mCACd,IAAI;IAAA;IAItB,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACH,MAAM,GAAGE,YAAY,CAACF,MAAO;IAClC,IAAI,CAACC,QAAQ,GAAGC,YAAY,CAACD,QAAS;IACtC,IAAI,CAACC,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACE,aAAa,EAAE;EACtB;;EAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,wBAAuBC,UAA0B,EAAEC,KAAa,EAAE;MAChE,IAAMC,GAAG,GAAG,IAAIZ,IAAI,EAAE;MAEtBY,GAAG,CAACC,aAAa,CAACH,UAAU,CAACI,GAAG,CAAC,UAAAC,IAAI;QAAA,OAAI,IAAIZ,OAAO,CAACY,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,CAAC;MAAA,EAAC,CAAC;MAEjF,IAAMC,MAAM,GAAGJ,GAAG,CAACK,SAAS,CAAC,IAAId,OAAO,EAAE,CAAC;MAC3C,IAAMe,IAAI,GAAGN,GAAG,CAACO,OAAO,CAAC,IAAIhB,OAAO,EAAE,CAAC;MACvC,IAAMiB,YA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AACN,MAAM,CAACwF,cAAc,CAACzB,CAAC,GAAGe,CAAC;QAElC,IAAMW,eAAe,GAAGrB,4BAA4B,CAACsB,WAAW,CAACvB,cAAc,EAAE3C,QAAQ,EAAEqD,CAAC,CAAC;QAC7F,MAAI,CAAC7E,MAAM,CAACwB,QAAQ,CAAC6C,IAAI,CAACoB,eAAe,CAAC;QAC1C,CAAAvB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEf,QAAQ,KAAIe,OAAO,CAACf,QAAQ,CAAC;UAAE3B,QAAQ,EAAEiE,eAAe;UAAErC,MAAM,EAANA;QAAO,CAAC,CAAC;MAC9E,CAAC,CAAC,CACDuC,UAAU,CAAC,YAAM;QAChBrB,qBAAqB,CAAC,YAAM;UAC1B,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEb,UAAU,KAAIa,OAAO,CAACb,UAAU,EAAE;QAC7C,CAAC,CAAC;QAEF,MAAI,CAACpD,QAAQ,CAACiF,OAAO,GAAG,IAAI;QAE5BU,UAAU,CAAC,YAAM;UACf,MAAI,CAACT,kBAAkB,GAAG,KAAK;QACjC,CAAC,CAAC;MACJ,CAAC,CAAC,CACDU,KAAK,EAAE;IACZ;EAAC;EAAA;AAAA;AAGH,eAAe9F,MAAM"}
|
|
1
|
+
{"version":3,"names":["Box3","MathUtils","TWEEN","Vector3","Camera","camera","controls","sceneControl","handleChanged","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","isTrigger","onUpdate","lookat","onComplate","toArray","userInput","Array","isArray","caclCurrentPos","moveCameraTo","caclSingleCoordinate","fromArray","_","x","y","z","options","currentPoition","currentPositionInterpolation","copy","requestAnimationFrame","renderer","render","scene","tween","stop","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, SceneControl } from '@anov/3d-core'\nimport { Box3, MathUtils, TWEEN, Vector3 } from '@anov/3d-core'\n\ntype vector3Array = number[]\ninterface ChangeCameraPresetOptions {\n duration?: number\n onUpdate?: (params: { position: Vector3; lookat: Vector3 }) => void\n onStart?: () => void\n onComplate?: () => void\n isTrigger?: boolean\n}\n\nclass Camera {\n private camera: PerspectiveCamera\n private controls: OrbitControls\n private sceneControl: SceneControl\n private isTransitionPeriod = false\n private isTrigger = true\n private tween: any\n\n constructor(camera: PerspectiveCamera, controls: OrbitControls, sceneControl: SceneControl) {\n this.camera = sceneControl.camera!\n this.controls = sceneControl.controls!\n this.sceneControl = sceneControl\n\n this.handleChanged()\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 * caclSingleCoordinate\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 * handle camera changed\n */\n private handleChanged() {\n // this.controls.addEventListener('change', () => {\n // // if (this.isTransitionPeriod)\n // // this.sceneControl.renderer!.render(this.sceneControl.scene!, this.sceneControl.camera!)\n // })\n }\n\n /**\n * focus On Position\n * @param params\n */\n focus(params: { target: vector3Array | vector3Array[]; pitch?: number; duration?: number; isTrigger?: boolean }) {\n return new Promise((res) => {\n const { target: position, pitch, duration } = params\n const moveOptions = () => ({\n duration: (duration && duration * 1000) ?? 1000,\n isTrigger: params.isTrigger ?? true,\n onUpdate: ({ position, lookat }) => {\n this.isTrigger = params.isTrigger ?? true\n },\n onComplate: () => {\n this.isTrigger = false\n\n res({\n position: this.camera.position.toArray(),\n target: this.controls.target.toArray(),\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 isTrigger: params.isTrigger ?? true,\n duration: (params.duration && params.duration * 1000) ?? 1000,\n onUpdate: ({ position, lookat }) => {\n this.isTrigger = params.isTrigger ?? true\n },\n onComplate: () => {\n this.isTrigger = false\n\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.isTrigger = !options.isTrigger\n this.camera.position.copy(position)\n this.controls.target.copy(target)\n\n requestAnimationFrame(() => {\n options?.onComplate && options.onComplate()\n this.sceneControl.renderer!.render(this.sceneControl.scene!, this.sceneControl.camera!)\n })\n\n return\n }\n\n if (this.tween)\n this.tween.stop()\n\n this.tween = 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 requestAnimationFrame(() => {\n options?.onComplate && options.onComplate()\n })\n\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,IAWzDC,MAAM;EAQV,gBAAYC,MAAyB,EAAEC,QAAuB,EAAEC,YAA0B,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA,4CAJ/D,KAAK;IAAA,mCACd,IAAI;IAAA;IAItB,IAAI,CAACF,MAAM,GAAGE,YAAY,CAACF,MAAO;IAClC,IAAI,CAACC,QAAQ,GAAGC,YAAY,CAACD,QAAS;IACtC,IAAI,CAACC,YAAY,GAAGA,YAAY;IAEhC,IAAI,CAACC,aAAa,EAAE;EACtB;;EAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,wBAAuBC,UAA0B,EAAEC,KAAa,EAAE;MAChE,IAAMC,GAAG,GAAG,IAAIX,IAAI,EAAE;MAEtBW,GAAG,CAACC,aAAa,CAACH,UAAU,CAACI,GAAG,CAAC,UAAAC,IAAI;QAAA,OAAI,IAAIX,OAAO,CAACW,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,CAAC;MAAA,EAAC,CAAC;MAEjF,IAAMC,MAAM,GAAGJ,GAAG,CAACK,SAAS,CAAC,IAAIb,OAAO,EAAE,CAAC;MAC3C,IAAMc,IAAI,GAAGN,GAAG,CAACO,OAAO,CAAC,IAAIf,OAAO,EAAE,CAAC;MACvC,IAAMgB,YAAY,GAAGF,IAAI,CAACG,MAA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AGrB,4BAA4B,CAACsB,WAAW,CAACvB,cAAc,EAAE5C,QAAQ,EAAEsD,CAAC,CAAC;QAC7F,MAAI,CAAC7E,MAAM,CAACuB,QAAQ,CAAC8C,IAAI,CAACoB,eAAe,CAAC;QAC1C,CAAAvB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEf,QAAQ,KAAIe,OAAO,CAACf,QAAQ,CAAC;UAAE5B,QAAQ,EAAEkE,eAAe;UAAErC,MAAM,EAANA;QAAO,CAAC,CAAC;MAC9E,CAAC,CAAC,CACDuC,UAAU,CAAC,YAAM;QAChBrB,qBAAqB,CAAC,YAAM;UAC1B,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEb,UAAU,KAAIa,OAAO,CAACb,UAAU,EAAE;QAC7C,CAAC,CAAC;QAEF,MAAI,CAACpD,QAAQ,CAACiF,OAAO,GAAG,IAAI;QAE5BU,UAAU,CAAC,YAAM;UACf,MAAI,CAACT,kBAAkB,GAAG,KAAK;QACjC,CAAC,CAAC;MACJ,CAAC,CAAC,CACDU,KAAK,EAAE;IACZ;EAAC;EAAA;AAAA;AAGH,eAAe9F,MAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICON样式基础类
|
|
3
|
+
*/
|
|
4
|
+
declare class IconStyle {
|
|
5
|
+
source: string;
|
|
6
|
+
color: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
constructor({ source, color, width, height }?: {
|
|
10
|
+
source?: string | undefined;
|
|
11
|
+
color?: string | undefined;
|
|
12
|
+
width?: number | undefined;
|
|
13
|
+
height?: number | undefined;
|
|
14
|
+
});
|
|
15
|
+
set(key: keyof this, value: any): void;
|
|
16
|
+
}
|
|
17
|
+
export default IconStyle;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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
|
+
/**
|
|
9
|
+
* ICON样式基础类
|
|
10
|
+
*/
|
|
11
|
+
var IconStyle = /*#__PURE__*/function () {
|
|
12
|
+
function IconStyle() {
|
|
13
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14
|
+
_ref$source = _ref.source,
|
|
15
|
+
source = _ref$source === void 0 ? '' : _ref$source,
|
|
16
|
+
_ref$color = _ref.color,
|
|
17
|
+
color = _ref$color === void 0 ? '#ffffff' : _ref$color,
|
|
18
|
+
_ref$width = _ref.width,
|
|
19
|
+
width = _ref$width === void 0 ? 200 : _ref$width,
|
|
20
|
+
_ref$height = _ref.height,
|
|
21
|
+
height = _ref$height === void 0 ? 100 : _ref$height;
|
|
22
|
+
_classCallCheck(this, IconStyle);
|
|
23
|
+
_defineProperty(this, "source", void 0);
|
|
24
|
+
_defineProperty(this, "color", void 0);
|
|
25
|
+
_defineProperty(this, "width", void 0);
|
|
26
|
+
_defineProperty(this, "height", void 0);
|
|
27
|
+
this.source = source;
|
|
28
|
+
this.color = color;
|
|
29
|
+
this.width = width;
|
|
30
|
+
this.height = height;
|
|
31
|
+
}
|
|
32
|
+
_createClass(IconStyle, [{
|
|
33
|
+
key: "set",
|
|
34
|
+
value: function set(key, value) {
|
|
35
|
+
if (key in this) this[key] = value;else console.warn("Property ".concat(String(key), " does not exist on ImageProperty"));
|
|
36
|
+
}
|
|
37
|
+
}]);
|
|
38
|
+
return IconStyle;
|
|
39
|
+
}();
|
|
40
|
+
export default IconStyle;
|
|
41
|
+
//# sourceMappingURL=IconStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IconStyle","source","color","width","height","key","value","console","warn","String"],"sources":["../../src/common/IconStyle.ts"],"sourcesContent":["/**\n * ICON样式基础类\n */\n\nclass IconStyle {\n source: string\n color: string\n width: number\n height: number\n\n constructor({ source = '', color = '#ffffff', width = 200, height = 100 } = {}) {\n this.source = source\n this.color = color\n this.width = width\n this.height = height\n }\n\n set(key: keyof this, value: any) {\n if (key in this)\n this[key] = value\n else\n console.warn(`Property ${String(key)} does not exist on ImageProperty`)\n }\n}\n\nexport default IconStyle\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,IAIMA,SAAS;EAMb,qBAAgF;IAAA,+EAAJ,CAAC,CAAC;MAAA,mBAAhEC,MAAM;MAANA,MAAM,4BAAG,EAAE;MAAA,kBAAEC,KAAK;MAALA,KAAK,2BAAG,SAAS;MAAA,kBAAEC,KAAK;MAALA,KAAK,2BAAG,GAAG;MAAA,mBAAEC,MAAM;MAANA,MAAM,4BAAG,GAAG;IAAA;IAAA;IAAA;IAAA;IAAA;IACrE,IAAI,CAACH,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,MAAM,GAAGA,MAAM;EACtB;EAAC;IAAA;IAAA,OAED,aAAIC,GAAe,EAAEC,KAAU,EAAE;MAC/B,IAAID,GAAG,IAAI,IAAI,EACb,IAAI,CAACA,GAAG,CAAC,GAAGC,KAAK,MAEjBC,OAAO,CAACC,IAAI,oBAAaC,MAAM,CAACJ,GAAG,CAAC,sCAAmC;IAC3E;EAAC;EAAA;AAAA;AAGH,eAAeL,SAAS"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 图片样式基础类
|
|
3
|
+
*/
|
|
4
|
+
declare class ImageStyle {
|
|
5
|
+
source: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
constructor({ source, width, height }?: {
|
|
9
|
+
source?: string | undefined;
|
|
10
|
+
width?: number | undefined;
|
|
11
|
+
height?: number | undefined;
|
|
12
|
+
});
|
|
13
|
+
set(key: keyof this, value: any): void;
|
|
14
|
+
}
|
|
15
|
+
export default ImageStyle;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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
|
+
/**
|
|
9
|
+
* 图片样式基础类
|
|
10
|
+
*/
|
|
11
|
+
var ImageStyle = /*#__PURE__*/function () {
|
|
12
|
+
function ImageStyle() {
|
|
13
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14
|
+
_ref$source = _ref.source,
|
|
15
|
+
source = _ref$source === void 0 ? '' : _ref$source,
|
|
16
|
+
_ref$width = _ref.width,
|
|
17
|
+
width = _ref$width === void 0 ? 200 : _ref$width,
|
|
18
|
+
_ref$height = _ref.height,
|
|
19
|
+
height = _ref$height === void 0 ? 100 : _ref$height;
|
|
20
|
+
_classCallCheck(this, ImageStyle);
|
|
21
|
+
_defineProperty(this, "source", void 0);
|
|
22
|
+
_defineProperty(this, "width", void 0);
|
|
23
|
+
_defineProperty(this, "height", void 0);
|
|
24
|
+
this.source = source;
|
|
25
|
+
this.width = width;
|
|
26
|
+
this.height = height;
|
|
27
|
+
}
|
|
28
|
+
_createClass(ImageStyle, [{
|
|
29
|
+
key: "set",
|
|
30
|
+
value: function set(key, value) {
|
|
31
|
+
if (key in this) this[key] = value;else console.warn("Property ".concat(String(key), " does not exist on ImageProperty"));
|
|
32
|
+
}
|
|
33
|
+
}]);
|
|
34
|
+
return ImageStyle;
|
|
35
|
+
}();
|
|
36
|
+
export default ImageStyle;
|
|
37
|
+
//# sourceMappingURL=ImageStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ImageStyle","source","width","height","key","value","console","warn","String"],"sources":["../../src/common/ImageStyle.ts"],"sourcesContent":["/**\n * 图片样式基础类\n */\n\nclass ImageStyle {\n source: string\n width: number\n height: number\n\n constructor({ source = '', width = 200, height = 100 } = {}) {\n this.source = source\n this.width = width\n this.height = height\n }\n\n set(key: keyof this, value: any) {\n if (key in this)\n this[key] = value\n else\n console.warn(`Property ${String(key)} does not exist on ImageProperty`)\n }\n}\n\nexport default ImageStyle\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,IAIMA,UAAU;EAKd,sBAA6D;IAAA,+EAAJ,CAAC,CAAC;MAAA,mBAA7CC,MAAM;MAANA,MAAM,4BAAG,EAAE;MAAA,kBAAEC,KAAK;MAALA,KAAK,2BAAG,GAAG;MAAA,mBAAEC,MAAM;MAANA,MAAM,4BAAG,GAAG;IAAA;IAAA;IAAA;IAAA;IAClD,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,MAAM,GAAGA,MAAM;EACtB;EAAC;IAAA;IAAA,OAED,aAAIC,GAAe,EAAEC,KAAU,EAAE;MAC/B,IAAID,GAAG,IAAI,IAAI,EACb,IAAI,CAACA,GAAG,CAAC,GAAGC,KAAK,MAEjBC,OAAO,CAACC,IAAI,oBAAaC,MAAM,CAACJ,GAAG,CAAC,sCAAmC;IAC3E;EAAC;EAAA;AAAA;AAGH,eAAeJ,UAAU"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文字样式基础类
|
|
3
|
+
*/
|
|
4
|
+
declare class LabelStyle {
|
|
5
|
+
text: string;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
fontColor: string;
|
|
8
|
+
fontWeight: string | number;
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
constructor({ text, fontSize, fontColor, fontWeight, fontFamily }?: {
|
|
11
|
+
text?: string | undefined;
|
|
12
|
+
fontSize?: number | undefined;
|
|
13
|
+
fontColor?: string | undefined;
|
|
14
|
+
fontWeight?: string | undefined;
|
|
15
|
+
fontFamily?: string | undefined;
|
|
16
|
+
});
|
|
17
|
+
setText(text: string): void;
|
|
18
|
+
setFontSize(size: number): void;
|
|
19
|
+
setFontColor(color: string): void;
|
|
20
|
+
setFontWeight(weight: string | number): void;
|
|
21
|
+
setFontFamily(family: string): void;
|
|
22
|
+
set(key: keyof this, value: any): void;
|
|
23
|
+
}
|
|
24
|
+
export default LabelStyle;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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
|
+
/**
|
|
9
|
+
* 文字样式基础类
|
|
10
|
+
*/
|
|
11
|
+
var LabelStyle = /*#__PURE__*/function () {
|
|
12
|
+
function LabelStyle() {
|
|
13
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14
|
+
_ref$text = _ref.text,
|
|
15
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
16
|
+
_ref$fontSize = _ref.fontSize,
|
|
17
|
+
fontSize = _ref$fontSize === void 0 ? 16 : _ref$fontSize,
|
|
18
|
+
_ref$fontColor = _ref.fontColor,
|
|
19
|
+
fontColor = _ref$fontColor === void 0 ? '#ffffff' : _ref$fontColor,
|
|
20
|
+
_ref$fontWeight = _ref.fontWeight,
|
|
21
|
+
fontWeight = _ref$fontWeight === void 0 ? 'normal' : _ref$fontWeight,
|
|
22
|
+
_ref$fontFamily = _ref.fontFamily,
|
|
23
|
+
fontFamily = _ref$fontFamily === void 0 ? '' : _ref$fontFamily;
|
|
24
|
+
_classCallCheck(this, LabelStyle);
|
|
25
|
+
_defineProperty(this, "text", void 0);
|
|
26
|
+
_defineProperty(this, "fontSize", void 0);
|
|
27
|
+
_defineProperty(this, "fontColor", void 0);
|
|
28
|
+
_defineProperty(this, "fontWeight", void 0);
|
|
29
|
+
_defineProperty(this, "fontFamily", void 0);
|
|
30
|
+
this.text = text;
|
|
31
|
+
this.fontSize = fontSize;
|
|
32
|
+
this.fontColor = fontColor;
|
|
33
|
+
this.fontWeight = fontWeight;
|
|
34
|
+
this.fontFamily = fontFamily;
|
|
35
|
+
}
|
|
36
|
+
_createClass(LabelStyle, [{
|
|
37
|
+
key: "setText",
|
|
38
|
+
value: function setText(text) {
|
|
39
|
+
this.text = text;
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "setFontSize",
|
|
43
|
+
value: function setFontSize(size) {
|
|
44
|
+
this.fontSize = size;
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "setFontColor",
|
|
48
|
+
value: function setFontColor(color) {
|
|
49
|
+
this.fontColor = color;
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "setFontWeight",
|
|
53
|
+
value: function setFontWeight(weight) {
|
|
54
|
+
this.fontWeight = weight;
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "setFontFamily",
|
|
58
|
+
value: function setFontFamily(family) {
|
|
59
|
+
this.fontFamily = family;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "set",
|
|
63
|
+
value: function set(key, value) {
|
|
64
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
65
|
+
if (this.hasOwnProperty(key)) this[key] = value;else console.warn("Property ".concat(String(key), " does not exist on Text"));
|
|
66
|
+
}
|
|
67
|
+
}]);
|
|
68
|
+
return LabelStyle;
|
|
69
|
+
}();
|
|
70
|
+
export default LabelStyle;
|
|
71
|
+
//# sourceMappingURL=LabelStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LabelStyle","text","fontSize","fontColor","fontWeight","fontFamily","size","color","weight","family","key","value","hasOwnProperty","console","warn","String"],"sources":["../../src/common/LabelStyle.ts"],"sourcesContent":["/**\n * 文字样式基础类\n */\n\nclass LabelStyle {\n text: string\n fontSize: number\n fontColor: string\n fontWeight: string | number\n fontFamily: string\n\n constructor({ text = '', fontSize = 16, fontColor = '#ffffff', fontWeight = 'normal', fontFamily = '' } = {}) {\n this.text = text\n this.fontSize = fontSize\n this.fontColor = fontColor\n this.fontWeight = fontWeight\n this.fontFamily = fontFamily\n }\n\n setText(text: string) {\n this.text = text\n }\n\n setFontSize(size: number) {\n this.fontSize = size\n }\n\n setFontColor(color: string) {\n this.fontColor = color\n }\n\n setFontWeight(weight: string | number) {\n this.fontWeight = weight\n }\n\n setFontFamily(family: string) {\n this.fontFamily = family\n }\n\n set(key: keyof this, value: any) {\n // eslint-disable-next-line no-prototype-builtins\n if (this.hasOwnProperty(key))\n this[key] = value\n else\n console.warn(`Property ${String(key)} does not exist on Text`)\n }\n}\n\nexport default LabelStyle\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,IAIMA,UAAU;EAOd,sBAA8G;IAAA,+EAAJ,CAAC,CAAC;MAAA,iBAA9FC,IAAI;MAAJA,IAAI,0BAAG,EAAE;MAAA,qBAAEC,QAAQ;MAARA,QAAQ,8BAAG,EAAE;MAAA,sBAAEC,SAAS;MAATA,SAAS,+BAAG,SAAS;MAAA,uBAAEC,UAAU;MAAVA,UAAU,gCAAG,QAAQ;MAAA,uBAAEC,UAAU;MAAVA,UAAU,gCAAG,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACnG,IAAI,CAACJ,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,UAAU,GAAGA,UAAU;EAC9B;EAAC;IAAA;IAAA,OAED,iBAAQJ,IAAY,EAAE;MACpB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAClB;EAAC;IAAA;IAAA,OAED,qBAAYK,IAAY,EAAE;MACxB,IAAI,CAACJ,QAAQ,GAAGI,IAAI;IACtB;EAAC;IAAA;IAAA,OAED,sBAAaC,KAAa,EAAE;MAC1B,IAAI,CAACJ,SAAS,GAAGI,KAAK;IACxB;EAAC;IAAA;IAAA,OAED,uBAAcC,MAAuB,EAAE;MACrC,IAAI,CAACJ,UAAU,GAAGI,MAAM;IAC1B;EAAC;IAAA;IAAA,OAED,uBAAcC,MAAc,EAAE;MAC5B,IAAI,CAACJ,UAAU,GAAGI,MAAM;IAC1B;EAAC;IAAA;IAAA,OAED,aAAIC,GAAe,EAAEC,KAAU,EAAE;MAC/B;MACA,IAAI,IAAI,CAACC,cAAc,CAACF,GAAG,CAAC,EAC1B,IAAI,CAACA,GAAG,CAAC,GAAGC,KAAK,MAEjBE,OAAO,CAACC,IAAI,oBAAaC,MAAM,CAACL,GAAG,CAAC,6BAA0B;IAClE;EAAC;EAAA;AAAA;AAGH,eAAeV,UAAU"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Object3D } from '@anov/3d-core';
|
|
2
|
+
declare class Component extends Object3D {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
children: [];
|
|
6
|
+
isComponent: boolean;
|
|
7
|
+
constructor();
|
|
8
|
+
onUpdate(): void;
|
|
9
|
+
onDestroy(): void;
|
|
10
|
+
create(): void;
|
|
11
|
+
delete(): void;
|
|
12
|
+
update(): void;
|
|
13
|
+
get(): void;
|
|
14
|
+
}
|
|
15
|
+
export default Component;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { Object3D } from '@anov/3d-core';
|
|
16
|
+
var Component = /*#__PURE__*/function (_Object3D) {
|
|
17
|
+
_inherits(Component, _Object3D);
|
|
18
|
+
var _super = _createSuper(Component);
|
|
19
|
+
function Component() {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, Component);
|
|
22
|
+
_this = _super.call(this);
|
|
23
|
+
_defineProperty(_assertThisInitialized(_this), "id", void 0);
|
|
24
|
+
_defineProperty(_assertThisInitialized(_this), "name", void 0);
|
|
25
|
+
_defineProperty(_assertThisInitialized(_this), "children", void 0);
|
|
26
|
+
_defineProperty(_assertThisInitialized(_this), "isComponent", void 0);
|
|
27
|
+
_this.isComponent = true;
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 生命周期
|
|
32
|
+
// // 在对象渲染之前直接执行
|
|
33
|
+
// onBeforeRender() {}
|
|
34
|
+
// // 在对象渲染之后直接执行
|
|
35
|
+
// onAfterRender() {}
|
|
36
|
+
// 每帧调用进入
|
|
37
|
+
_createClass(Component, [{
|
|
38
|
+
key: "onUpdate",
|
|
39
|
+
value: function onUpdate() {}
|
|
40
|
+
// 销毁
|
|
41
|
+
}, {
|
|
42
|
+
key: "onDestroy",
|
|
43
|
+
value: function onDestroy() {}
|
|
44
|
+
|
|
45
|
+
// 新增
|
|
46
|
+
}, {
|
|
47
|
+
key: "create",
|
|
48
|
+
value: function create() {}
|
|
49
|
+
// 删除
|
|
50
|
+
}, {
|
|
51
|
+
key: "delete",
|
|
52
|
+
value: function _delete() {
|
|
53
|
+
var _this$parent;
|
|
54
|
+
this.onDestroy();
|
|
55
|
+
(_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.remove(this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 修改
|
|
59
|
+
}, {
|
|
60
|
+
key: "update",
|
|
61
|
+
value: function update() {}
|
|
62
|
+
// 获取
|
|
63
|
+
}, {
|
|
64
|
+
key: "get",
|
|
65
|
+
value: function get() {}
|
|
66
|
+
}]);
|
|
67
|
+
return Component;
|
|
68
|
+
}(Object3D);
|
|
69
|
+
export default Component;
|
|
70
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Object3D","Component","isComponent","onDestroy","parent","remove"],"sources":["../../src/common/component.ts"],"sourcesContent":["import { Object3D } from '@anov/3d-core'\n\nclass Component extends Object3D {\n id!: number\n name!: string\n children!: []\n isComponent: boolean\n\n constructor() {\n super()\n this.isComponent = true\n }\n\n // 生命周期\n // // 在对象渲染之前直接执行\n // onBeforeRender() {}\n // // 在对象渲染之后直接执行\n // onAfterRender() {}\n // 每帧调用进入\n onUpdate() {}\n // 销毁\n onDestroy() {}\n\n // 新增\n create() { }\n // 删除\n delete() {\n this.onDestroy()\n this.parent?.remove(this)\n }\n\n // 修改\n update() { }\n // 获取\n get() { }\n}\n\nexport default Component"],"mappings":";;;;;;;;;;;;;;AAAA,SAASA,QAAQ,QAAQ,eAAe;AAAA,IAElCC,SAAS;EAAA;EAAA;EAMb,qBAAc;IAAA;IAAA;IACZ;IAAO;IAAA;IAAA;IAAA;IACP,MAAKC,WAAW,GAAG,IAAI;IAAA;EACzB;;EAEA;EACA;EACA;EACA;EACA;EACA;EAAA;IAAA;IAAA,OACA,oBAAW,CAAC;IACZ;EAAA;IAAA;IAAA,OACA,qBAAY,CAAC;;IAEb;EAAA;IAAA;IAAA,OACA,kBAAS,CAAE;IACX;EAAA;IAAA;IAAA,OACA,mBAAS;MAAA;MACP,IAAI,CAACC,SAAS,EAAE;MAChB,oBAAI,CAACC,MAAM,iDAAX,aAAaC,MAAM,CAAC,IAAI,CAAC;IAC3B;;IAEA;EAAA;IAAA;IAAA,OACA,kBAAS,CAAE;IACX;EAAA;IAAA;IAAA,OACA,eAAM,CAAE;EAAC;EAAA;AAAA,EAhCaL,QAAQ;AAmChC,eAAeC,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RenderType"],"sources":["../../src/common/constant.ts"],"sourcesContent":["export enum RenderType {\n Sprite = 'Sprite', // 2D精灵图,始终面向镜头,跟随场景缩放\n Plane = 'Plane', // 3D绘制,跟随场景旋转、缩放\n Fixed = 'Fixed', // 2D绘制,不支持缩放,始终面向镜头\n}\n"],"mappings":"AAAA,WAAYA,UAAU,EAGH;AAClB,WAJWA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,KAAVA,UAAU"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 _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); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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
|
+
var ControlBaseModule = /*#__PURE__*/_createClass(function ControlBaseModule(camera, dom) {
|
|
9
|
+
_classCallCheck(this, ControlBaseModule);
|
|
10
|
+
_defineProperty(this, "camera", void 0);
|
|
11
|
+
_defineProperty(this, "dom", void 0);
|
|
12
|
+
this.camera = camera;
|
|
13
|
+
this.dom = dom;
|
|
14
|
+
});
|
|
15
|
+
export default ControlBaseModule;
|
|
16
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ControlBaseModule","camera","dom"],"sources":["../../src/controls/base.ts"],"sourcesContent":["import type { Camera } from '@anov/3d-core'\n\nclass ControlBaseModule {\n camera: Camera\n dom: HTMLElement\n\n constructor(camera: Camera, dom: HTMLElement) {\n this.camera = camera\n this.dom = dom\n }\n}\n\nexport default ControlBaseModule"],"mappings":";;;;;;;IAEMA,iBAAiB,6BAIrB,2BAAYC,MAAc,EAAEC,GAAgB,EAAE;EAAA;EAAA;EAAA;EAC5C,IAAI,CAACD,MAAM,GAAGA,MAAM;EACpB,IAAI,CAACC,GAAG,GAAGA,GAAG;AAChB,CAAC;AAGH,eAAeF,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FirstViewControl"],"sources":["../../src/controls/index.ts"],"sourcesContent":["import FirstViewControl from './src/FirstViewControl'\n\nexport {\n FirstViewControl,\n}"],"mappings":"AAAA,OAAOA,gBAAgB;AAEvB,SACEA,gBAAgB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Camera } from '@anov/3d-core';
|
|
2
|
+
import { Vector3, lib } from '@anov/3d-core';
|
|
3
|
+
import type ControlBaseModule from '../base';
|
|
4
|
+
/**
|
|
5
|
+
* @class FirstViewControl - First view control module
|
|
6
|
+
*
|
|
7
|
+
* 贴地 (First View) 控制模块
|
|
8
|
+
*/
|
|
9
|
+
declare class FirstViewControl implements ControlBaseModule {
|
|
10
|
+
camera: Camera;
|
|
11
|
+
dom: HTMLElement;
|
|
12
|
+
control: lib.PointerLockControls;
|
|
13
|
+
velocity: Vector3;
|
|
14
|
+
private moveForward;
|
|
15
|
+
private moveBackward;
|
|
16
|
+
private moveLeft;
|
|
17
|
+
private moveRight;
|
|
18
|
+
private canJump;
|
|
19
|
+
private direction;
|
|
20
|
+
private prevTime;
|
|
21
|
+
private cancellation;
|
|
22
|
+
constructor(camera: Camera, dom: HTMLElement);
|
|
23
|
+
/**
|
|
24
|
+
* registerEvent
|
|
25
|
+
*/
|
|
26
|
+
private registerEvent;
|
|
27
|
+
private update;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
export default FirstViewControl;
|