@anov/3d-ability 0.0.24 → 0.0.25
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/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 +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- 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,I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AC;QAEjC,IAAI9C,KAAK;UACP;UACA,MAAI,CAACN,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;M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,CAAC,GAAGe,CAAC;QAElC,IAAMW,eAAe,GAAGrB,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,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;
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
import { Vector3, lib, use } from '@anov/3d-core';
|
|
9
|
+
var PointerLockControls = lib.PointerLockControls;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @class FirstViewControl - First view control module
|
|
13
|
+
*
|
|
14
|
+
* 贴地 (First View) 控制模块
|
|
15
|
+
*/
|
|
16
|
+
var FirstViewControl = /*#__PURE__*/function () {
|
|
17
|
+
function FirstViewControl(camera, dom) {
|
|
18
|
+
var _this = this;
|
|
19
|
+
_classCallCheck(this, FirstViewControl);
|
|
20
|
+
_defineProperty(this, "camera", void 0);
|
|
21
|
+
_defineProperty(this, "dom", void 0);
|
|
22
|
+
_defineProperty(this, "control", void 0);
|
|
23
|
+
_defineProperty(this, "velocity", new Vector3());
|
|
24
|
+
_defineProperty(this, "moveForward", false);
|
|
25
|
+
_defineProperty(this, "moveBackward", false);
|
|
26
|
+
_defineProperty(this, "moveLeft", false);
|
|
27
|
+
_defineProperty(this, "moveRight", false);
|
|
28
|
+
_defineProperty(this, "canJump", false);
|
|
29
|
+
_defineProperty(this, "direction", new Vector3());
|
|
30
|
+
_defineProperty(this, "prevTime", performance.now());
|
|
31
|
+
_defineProperty(this, "cancellation", void 0);
|
|
32
|
+
this.camera = camera;
|
|
33
|
+
this.dom = dom;
|
|
34
|
+
this.control = new PointerLockControls(camera, document.body);
|
|
35
|
+
this.dom.addEventListener('click', this.control.lock);
|
|
36
|
+
this.registerEvent();
|
|
37
|
+
this.cancellation = use.useframe(function () {
|
|
38
|
+
_this.update();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* registerEvent
|
|
44
|
+
*/
|
|
45
|
+
_createClass(FirstViewControl, [{
|
|
46
|
+
key: "registerEvent",
|
|
47
|
+
value: function registerEvent() {
|
|
48
|
+
var _this2 = this;
|
|
49
|
+
var onKeyDown = function onKeyDown(event) {
|
|
50
|
+
switch (event.code) {
|
|
51
|
+
case 'ArrowUp':
|
|
52
|
+
case 'KeyW':
|
|
53
|
+
_this2.moveForward = true;
|
|
54
|
+
break;
|
|
55
|
+
case 'ArrowLeft':
|
|
56
|
+
case 'KeyA':
|
|
57
|
+
_this2.moveLeft = true;
|
|
58
|
+
break;
|
|
59
|
+
case 'ArrowDown':
|
|
60
|
+
case 'KeyS':
|
|
61
|
+
_this2.moveBackward = true;
|
|
62
|
+
break;
|
|
63
|
+
case 'ArrowRight':
|
|
64
|
+
case 'KeyD':
|
|
65
|
+
_this2.moveRight = true;
|
|
66
|
+
break;
|
|
67
|
+
case 'Space':
|
|
68
|
+
if (_this2.canJump === true) _this2.velocity.y += 5;
|
|
69
|
+
_this2.canJump = false;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var onKeyUp = function onKeyUp(event) {
|
|
74
|
+
switch (event.code) {
|
|
75
|
+
case 'ArrowUp':
|
|
76
|
+
case 'KeyW':
|
|
77
|
+
_this2.moveForward = false;
|
|
78
|
+
break;
|
|
79
|
+
case 'ArrowLeft':
|
|
80
|
+
case 'KeyA':
|
|
81
|
+
_this2.moveLeft = false;
|
|
82
|
+
break;
|
|
83
|
+
case 'ArrowDown':
|
|
84
|
+
case 'KeyS':
|
|
85
|
+
_this2.moveBackward = false;
|
|
86
|
+
break;
|
|
87
|
+
case 'ArrowRight':
|
|
88
|
+
case 'KeyD':
|
|
89
|
+
_this2.moveRight = false;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
document.addEventListener('keydown', onKeyDown);
|
|
94
|
+
document.addEventListener('keyup', onKeyUp);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "update",
|
|
98
|
+
value: function update() {
|
|
99
|
+
var time = performance.now();
|
|
100
|
+
if (this.control.isLocked) {
|
|
101
|
+
var delta = (time - this.prevTime) / 1000;
|
|
102
|
+
this.velocity.x -= this.velocity.x * 10.0 * delta;
|
|
103
|
+
this.velocity.z -= this.velocity.z * 10.0 * delta;
|
|
104
|
+
this.velocity.y -= 9.8 * 100.0 * delta;
|
|
105
|
+
this.direction.z = Number(this.moveForward) - Number(this.moveBackward);
|
|
106
|
+
this.direction.x = Number(this.moveRight) - Number(this.moveLeft);
|
|
107
|
+
this.direction.normalize();
|
|
108
|
+
if (this.moveForward || this.moveBackward) this.velocity.z -= this.direction.z * 100.0 * delta;
|
|
109
|
+
if (this.moveLeft || this.moveRight) this.velocity.x -= this.direction.x * 100.0 * delta;
|
|
110
|
+
this.control.moveRight(-this.velocity.x * delta);
|
|
111
|
+
this.control.moveForward(-this.velocity.z * delta);
|
|
112
|
+
this.control.getObject().position.y += this.velocity.y * delta;
|
|
113
|
+
if (this.control.getObject().position.y < 2) {
|
|
114
|
+
this.velocity.y = 0;
|
|
115
|
+
this.control.getObject().position.y = 1.8;
|
|
116
|
+
this.canJump = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.prevTime = time;
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "dispose",
|
|
123
|
+
value: function dispose() {
|
|
124
|
+
this.cancellation();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 检测专用
|
|
128
|
+
}]);
|
|
129
|
+
return FirstViewControl;
|
|
130
|
+
}();
|
|
131
|
+
export default FirstViewControl;
|
|
132
|
+
//# sourceMappingURL=FirstViewControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Vector3","lib","use","PointerLockControls","FirstViewControl","camera","dom","performance","now","control","document","body","addEventListener","lock","registerEvent","cancellation","useframe","update","onKeyDown","event","code","moveForward","moveLeft","moveBackward","moveRight","canJump","velocity","y","onKeyUp","time","isLocked","delta","prevTime","x","z","direction","Number","normalize","getObject","position"],"sources":["../../../src/controls/src/FirstViewControl.ts"],"sourcesContent":["import type { Camera } from '@anov/3d-core'\nimport { Vector3, lib, use } from '@anov/3d-core'\nimport type ControlBaseModule from '../base'\n\nconst { PointerLockControls } = lib\n\n/**\n * @class FirstViewControl - First view control module\n *\n * 贴地 (First View) 控制模块\n */\n\nclass FirstViewControl implements ControlBaseModule {\n camera: Camera\n dom: HTMLElement\n control: lib.PointerLockControls\n\n velocity = new Vector3()\n\n private moveForward = false\n private moveBackward = false\n private moveLeft = false\n private moveRight = false\n private canJump = false\n\n private direction = new Vector3()\n private prevTime = performance.now()\n private cancellation: () => void\n\n constructor(camera: Camera, dom: HTMLElement) {\n this.camera = camera\n this.dom = dom\n\n this.control = new PointerLockControls(camera, document.body)\n this.dom.addEventListener('click', this.control.lock)\n this.registerEvent()\n\n this.cancellation = use.useframe(() => {\n this.update()\n })\n }\n\n /**\n * registerEvent\n */\n private registerEvent() {\n const onKeyDown = (event: KeyboardEvent) => {\n switch (event.code) {\n case 'ArrowUp':\n case 'KeyW':\n this.moveForward = true\n break\n\n case 'ArrowLeft':\n case 'KeyA':\n this.moveLeft = true\n break\n\n case 'ArrowDown':\n case 'KeyS':\n this.moveBackward = true\n break\n\n case 'ArrowRight':\n case 'KeyD':\n this.moveRight = true\n break\n\n case 'Space':\n if (this.canJump === true)\n this.velocity.y += 5\n this.canJump = false\n break\n }\n }\n\n const onKeyUp = (event: KeyboardEvent) => {\n switch (event.code) {\n case 'ArrowUp':\n case 'KeyW':\n this.moveForward = false\n break\n\n case 'ArrowLeft':\n case 'KeyA':\n this.moveLeft = false\n break\n\n case 'ArrowDown':\n case 'KeyS':\n this.moveBackward = false\n break\n\n case 'ArrowRight':\n case 'KeyD':\n this.moveRight = false\n break\n }\n }\n\n document.addEventListener('keydown', onKeyDown)\n document.addEventListener('keyup', onKeyUp)\n }\n\n private update() {\n const time = performance.now()\n\n if (this.control.isLocked) {\n const delta = (time - this.prevTime) / 1000\n\n this.velocity.x -= this.velocity.x * 10.0 * delta\n this.velocity.z -= this.velocity.z * 10.0 * delta\n this.velocity.y -= 9.8 * 100.0 * delta\n\n this.direction.z = Number(this.moveForward) - Number(this.moveBackward)\n this.direction.x = Number(this.moveRight) - Number(this.moveLeft)\n this.direction.normalize()\n\n if (this.moveForward || this.moveBackward)\n this.velocity.z -= this.direction.z * 100.0 * delta\n\n if (this.moveLeft || this.moveRight)\n this.velocity.x -= this.direction.x * 100.0 * delta\n\n this.control.moveRight(-this.velocity.x * delta)\n this.control.moveForward(-this.velocity.z * delta)\n this.control.getObject().position.y += (this.velocity.y * delta)\n\n if (this.control.getObject().position.y < 2) {\n this.velocity.y = 0\n this.control.getObject().position.y = 1.8\n\n this.canJump = true\n }\n }\n\n this.prevTime = time\n }\n\n dispose() {\n this.cancellation()\n }\n\n // 检测专用\n}\n\nexport default FirstViewControl"],"mappings":";;;;;;;AACA,SAASA,OAAO,EAAEC,GAAG,EAAEC,GAAG,QAAQ,eAAe;AAGjD,IAAQC,mBAAmB,GAAKF,GAAG,CAA3BE,mBAAmB;;AAE3B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IAEA;EAAA;EAAA;AAAA;AAGF,eAAeX,gBAAgB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ import createBloomSelectedTool from './postEffects/bloomSelect';
|
|
|
25
25
|
import FakeGlowMaterial from './material/fakeGlowMaterial';
|
|
26
26
|
import Sky from './environment/skyv2';
|
|
27
27
|
import Weather from './weather';
|
|
28
|
+
import { FirstViewControl } from './controls/index';
|
|
28
29
|
export * from './scene';
|
|
29
30
|
export { SceneControl, // todo remove
|
|
30
31
|
createRain, createSnow, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, SkyBox, Fog2DMesh, Sky, Weather, Css2DPoi, Css3DPoi, SpritePoi, EAnimationType, HeatMap, FakeGlowMaterial, GridMaterial, initPostEffects, // effect
|
|
31
|
-
createHighSelectedTool, addColorifyPass, addBloom, addBrightnessContrastPass, addMappingExposurePass, createBloomSelectedTool, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, };
|
|
32
|
+
createHighSelectedTool, addColorifyPass, addBloom, addBrightnessContrastPass, addMappingExposurePass, createBloomSelectedTool, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, FirstViewControl, };
|
package/dist/index.js
CHANGED
|
@@ -25,10 +25,11 @@ import createBloomSelectedTool from "./postEffects/bloomSelect";
|
|
|
25
25
|
import FakeGlowMaterial from "./material/fakeGlowMaterial";
|
|
26
26
|
import Sky from "./environment/skyv2";
|
|
27
27
|
import Weather from "./weather";
|
|
28
|
+
import { FirstViewControl } from "./controls/index";
|
|
28
29
|
export * from "./scene";
|
|
29
30
|
export { SceneControl,
|
|
30
31
|
// todo remove
|
|
31
32
|
createRain, createSnow, createSun, createSkySystem, createVolumetricCloud, createSkyCloud, Snow, Rain, SkyBox, Fog2DMesh, Sky, Weather, Css2DPoi, Css3DPoi, SpritePoi, EAnimationType, HeatMap, FakeGlowMaterial, GridMaterial, initPostEffects,
|
|
32
33
|
// effect
|
|
33
|
-
createHighSelectedTool, addColorifyPass, addBloom, addBrightnessContrastPass, addMappingExposurePass, createBloomSelectedTool, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh };
|
|
34
|
+
createHighSelectedTool, addColorifyPass, addBloom, addBrightnessContrastPass, addMappingExposurePass, createBloomSelectedTool, ViewHelper, Camera, RoundLineGeometry, createRoundLineWallMesh, FirstViewControl };
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SceneControl","createSnow","createRain","initPostEffects","createHighSelectedTool","createSun","GridMaterial","ViewHelper","createSkySystem","createVolumetricCloud","createSkyCloud","Snow","Rain","Css2DPoi","Css3DPoi","EAnimationType","SpritePoi","HeatMap","SkyBox","Camera","RoundLineGeometry","createRoundLineWallMesh","Fog2DMesh","addColorifyPass","addBloom","addBrightnessContrastPass","addMappingExposurePass","createBloomSelectedTool","FakeGlowMaterial","Sky","Weather"],"sources":["../src/index.ts"],"sourcesContent":["import { SceneControl } from '@anov/3d-core'\nimport { createSnow } from './environment/snow'\nimport { createRain } from './environment/rain'\nimport { initPostEffects } from './postEffects'\nimport createHighSelectedTool from './postEffects/outlinePass'\nimport { createSun } from './environment/sun'\nimport GridMaterial from './material/pristineGridMaterial'\nimport ViewHelper from './helper/view'\nimport createSkySystem from './environment/sky'\nimport createVolumetricCloud from './environment/volumetricCloud/inex'\nimport createSkyCloud from './environment/shaderCloud/index'\nimport Snow from './environment/showShader'\nimport Rain from './environment/rainShader'\nimport { Css2DPoi, Css3DPoi, EAnimationType, SpritePoi } from './poi'\nimport HeatMap from './heatmap/index'\nimport SkyBox from './environment/skyBox'\nimport Camera from './camera/index'\nimport { RoundLineGeometry, createRoundLineWallMesh } from './line/round-curve'\nimport Fog2DMesh from './weather/objects/Fog2DMesh'\nimport addColorifyPass from './postEffects/colorifyPass'\nimport addBloom from './postEffects/bloomPass'\nimport addBrightnessContrastPass from './postEffects/addBrightnessContrastPass'\nimport addMappingExposurePass from './postEffects/addACESFilmicToneMappingPass'\nimport createBloomSelectedTool from './postEffects/bloomSelect'\nimport FakeGlowMaterial from './material/fakeGlowMaterial'\nimport Sky from './environment/skyv2'\nimport Weather from './weather'\n\nexport * from './scene'\n\nexport {\n SceneControl, // todo remove\n createRain,\n createSnow,\n createSun,\n createSkySystem,\n createVolumetricCloud,\n createSkyCloud,\n Snow,\n Rain,\n SkyBox,\n Fog2DMesh,\n Sky,\n Weather,\n\n Css2DPoi,\n Css3DPoi,\n SpritePoi,\n EAnimationType,\n\n HeatMap,\n\n FakeGlowMaterial,\n GridMaterial,\n\n initPostEffects, // effect\n createHighSelectedTool,\n addColorifyPass,\n addBloom,\n addBrightnessContrastPass,\n addMappingExposurePass,\n createBloomSelectedTool,\n\n ViewHelper,\n Camera,\n\n RoundLineGeometry,\n createRoundLineWallMesh,\n\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAe;AAC5C,SAASC,UAAU;AACnB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,OAAOC,sBAAsB;AAC7B,SAASC,SAAS;AAClB,OAAOC,YAAY;AACnB,OAAOC,UAAU;AACjB,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc;AACrB,OAAOC,IAAI;AACX,OAAOC,IAAI;AACX,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,SAAS;AACtD,OAAOC,OAAO;AACd,OAAOC,MAAM;AACb,OAAOC,MAAM;AACb,SAASC,iBAAiB,EAAEC,uBAAuB;AACnD,OAAOC,SAAS;AAChB,OAAOC,eAAe;AACtB,OAAOC,QAAQ;AACf,OAAOC,yBAAyB;AAChC,OAAOC,sBAAsB;AAC7B,OAAOC,uBAAuB;AAC9B,OAAOC,gBAAgB;AACvB,OAAOC,GAAG;AACV,OAAOC,OAAO;
|
|
1
|
+
{"version":3,"names":["SceneControl","createSnow","createRain","initPostEffects","createHighSelectedTool","createSun","GridMaterial","ViewHelper","createSkySystem","createVolumetricCloud","createSkyCloud","Snow","Rain","Css2DPoi","Css3DPoi","EAnimationType","SpritePoi","HeatMap","SkyBox","Camera","RoundLineGeometry","createRoundLineWallMesh","Fog2DMesh","addColorifyPass","addBloom","addBrightnessContrastPass","addMappingExposurePass","createBloomSelectedTool","FakeGlowMaterial","Sky","Weather","FirstViewControl"],"sources":["../src/index.ts"],"sourcesContent":["import { SceneControl } from '@anov/3d-core'\nimport { createSnow } from './environment/snow'\nimport { createRain } from './environment/rain'\nimport { initPostEffects } from './postEffects'\nimport createHighSelectedTool from './postEffects/outlinePass'\nimport { createSun } from './environment/sun'\nimport GridMaterial from './material/pristineGridMaterial'\nimport ViewHelper from './helper/view'\nimport createSkySystem from './environment/sky'\nimport createVolumetricCloud from './environment/volumetricCloud/inex'\nimport createSkyCloud from './environment/shaderCloud/index'\nimport Snow from './environment/showShader'\nimport Rain from './environment/rainShader'\nimport { Css2DPoi, Css3DPoi, EAnimationType, SpritePoi } from './poi'\nimport HeatMap from './heatmap/index'\nimport SkyBox from './environment/skyBox'\nimport Camera from './camera/index'\nimport { RoundLineGeometry, createRoundLineWallMesh } from './line/round-curve'\nimport Fog2DMesh from './weather/objects/Fog2DMesh'\nimport addColorifyPass from './postEffects/colorifyPass'\nimport addBloom from './postEffects/bloomPass'\nimport addBrightnessContrastPass from './postEffects/addBrightnessContrastPass'\nimport addMappingExposurePass from './postEffects/addACESFilmicToneMappingPass'\nimport createBloomSelectedTool from './postEffects/bloomSelect'\nimport FakeGlowMaterial from './material/fakeGlowMaterial'\nimport Sky from './environment/skyv2'\nimport Weather from './weather'\nimport { FirstViewControl } from './controls/index'\n\nexport * from './scene'\n\nexport {\n SceneControl, // todo remove\n createRain,\n createSnow,\n createSun,\n createSkySystem,\n createVolumetricCloud,\n createSkyCloud,\n Snow,\n Rain,\n SkyBox,\n Fog2DMesh,\n Sky,\n Weather,\n\n Css2DPoi,\n Css3DPoi,\n SpritePoi,\n EAnimationType,\n\n HeatMap,\n\n FakeGlowMaterial,\n GridMaterial,\n\n initPostEffects, // effect\n createHighSelectedTool,\n addColorifyPass,\n addBloom,\n addBrightnessContrastPass,\n addMappingExposurePass,\n createBloomSelectedTool,\n\n ViewHelper,\n Camera,\n\n RoundLineGeometry,\n createRoundLineWallMesh,\n\n FirstViewControl,\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAe;AAC5C,SAASC,UAAU;AACnB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,OAAOC,sBAAsB;AAC7B,SAASC,SAAS;AAClB,OAAOC,YAAY;AACnB,OAAOC,UAAU;AACjB,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc;AACrB,OAAOC,IAAI;AACX,OAAOC,IAAI;AACX,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,SAAS;AACtD,OAAOC,OAAO;AACd,OAAOC,MAAM;AACb,OAAOC,MAAM;AACb,SAASC,iBAAiB,EAAEC,uBAAuB;AACnD,OAAOC,SAAS;AAChB,OAAOC,eAAe;AACtB,OAAOC,QAAQ;AACf,OAAOC,yBAAyB;AAChC,OAAOC,sBAAsB;AAC7B,OAAOC,uBAAuB;AAC9B,OAAOC,gBAAgB;AACvB,OAAOC,GAAG;AACV,OAAOC,OAAO;AACd,SAASC,gBAAgB;AAEzB;AAEA,SACE/B,YAAY;AAAE;AACdE,UAAU,EACVD,UAAU,EACVI,SAAS,EACTG,eAAe,EACfC,qBAAqB,EACrBC,cAAc,EACdC,IAAI,EACJC,IAAI,EACJM,MAAM,EACNI,SAAS,EACTO,GAAG,EACHC,OAAO,EAEPjB,QAAQ,EACRC,QAAQ,EACRE,SAAS,EACTD,cAAc,EAEdE,OAAO,EAEPW,gBAAgB,EAChBtB,YAAY,EAEZH,eAAe;AAAE;AACjBC,sBAAsB,EACtBmB,eAAe,EACfC,QAAQ,EACRC,yBAAyB,EACzBC,sBAAsB,EACtBC,uBAAuB,EAEvBpB,UAAU,EACVY,MAAM,EAENC,iBAAiB,EACjBC,uBAAuB,EAEvBU,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anov/3d-ability",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"package.json"
|
|
17
17
|
],
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@anov/3d-core": "^0.0.
|
|
19
|
+
"@anov/3d-core": "^0.0.24"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@types/suncalc": "^1.9.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"suncalc": "^1.9.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@anov/3d-core": "^0.0.
|
|
29
|
+
"@anov/3d-core": "^0.0.24"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "father build",
|