华农3D项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

699 lines
22 KiB

2 months ago
  1. // 从这里开始
  2. var h1 = null
  3. var h2 = null
  4. var h3 = null
  5. var oldtransformNodex = null
  6. // var oldtransformNodeOther = null
  7. // var oldMesh = null
  8. var oldMeshOther = null
  9. var drag = null
  10. // var notmoveGroup = null
  11. // var movedGroup = null
  12. // var movesingle = false
  13. // var dynamicTexture = null
  14. // var dynamicTexture2 = null
  15. // var show = 50
  16. // var showdd = 50
  17. var isRotating = true
  18. var clickParentRotate = false
  19. // var targetAngles = {
  20. // default: { // 初始视角
  21. // alpha: 0,
  22. // beta: 0,
  23. // radius: 500
  24. // },
  25. // alarm: { // 报警视角(示例)
  26. // alpha: 6.2782, // -π(180度)
  27. // beta: 0, // π/4(45度)
  28. // radius: 500 // 更近的距离
  29. // }
  30. // }
  31. var camera
  32. BABYLON.DefaultLoadingScreen.prototype.displayLoadingUI = function() {
  33. if (document.getElementById('customLoadingScreenDiv')) {
  34. document.getElementById('customLoadingScreenDiv').style.display = 'initial'
  35. return
  36. }
  37. this._loadingDiv = document.createElement('div')
  38. // this._loadingDiv.style.height = '1750px';
  39. this._loadingDiv.id = 'customLoadingScreenDiv'
  40. thecss = 'lohingifpc'
  41. thecss2 = 'zcpc'
  42. this._loadingDiv.innerHTML = "<div class='oka'><div class='" + thecss + "'><image src='./logok.gif' class='jiazaiimg'/></div></div>"
  43. this._resizeLoadingUI()
  44. window.addEventListener('resize', this._resizeLoadingUI)
  45. document.body.appendChild(this._loadingDiv)
  46. }
  47. // var movebyName = function(nodeName) {
  48. // var x = scene.getTransformNodeByName(nodeName)
  49. // moveTrans(x)
  50. // }
  51. function prepareGroupButton2(transformNodex, color, qu) {
  52. var mesheses = null
  53. if (transformNodex.getClassName() === 'TransformNode') {
  54. mesheses = transformNodex.getChildMeshes(false)
  55. } else {
  56. mesheses = []
  57. mesheses.push(transformNodex)
  58. }
  59. for (var i = 0; i < mesheses.length; i++) {
  60. mesheses[i].actionManager = new BABYLON.ActionManager(scene)
  61. // var theScaling = mesheses[i].scaling
  62. /* if (true) {
  63. try {
  64. mesheses[i].actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOutTrigger, mesheses[i], "scaling", new BABYLON.Vector3(theScaling.x, theScaling.y, theScaling.z), 100));
  65. mesheses[i].actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOverTrigger, mesheses[i], "scaling", new BABYLON.Vector3(theScaling.x * 1.01, theScaling.y * 1.01, theScaling.z * 1.01), 100));
  66. } catch (error) {
  67. //alert(error)
  68. }
  69. }*/
  70. // var clickbegin = false
  71. mesheses[i].actionManager.registerAction(
  72. new BABYLON.ExecuteCodeAction({
  73. trigger: BABYLON.ActionManager.OnPointerOverTrigger,
  74. parameter: ''
  75. },
  76. function() {
  77. // clickbegin = true
  78. // if (true) {
  79. // if (oldtransformNodeOther != null) {
  80. // oldtransformNodeOther.removeBehavior(drag)
  81. // var mesheses2 = null
  82. // if (oldtransformNodeOther.getClassName() === 'TransformNode') {
  83. // mesheses2 = oldtransformNodeOther.getChildMeshes(false)
  84. // } else {
  85. // mesheses2 = []
  86. // mesheses2.push(oldtransformNodeOther)
  87. // }
  88. // for (var i = 0; i < mesheses2.length; i++) {
  89. // try {
  90. // h2.removeMesh(mesheses2[i])
  91. // } catch (error) {
  92. // // alert(error)
  93. // }
  94. // }
  95. // }
  96. // oldtransformNodeOther = transformNodex
  97. // // transformNodex.addBehavior(drag);
  98. // var mesheses3 = null
  99. // if (transformNodex.getClassName() === 'TransformNode') {
  100. // mesheses3 = transformNodex.getChildMeshes(false)
  101. // } else {
  102. // mesheses3 = []
  103. // mesheses3.push(transformNodex)
  104. // }
  105. // for (var i = 0; i < mesheses3.length; i++) {
  106. // try {
  107. // h2.addMesh(mesheses3[i], color)
  108. // } catch (error) {
  109. // // alert(error)
  110. // }
  111. // }
  112. isRotating = false
  113. camera.useAutoRotationBehavior = isRotating
  114. // }
  115. }
  116. )
  117. )
  118. // 移出事件
  119. mesheses[i].actionManager.registerAction(
  120. new BABYLON.ExecuteCodeAction({
  121. trigger: BABYLON.ActionManager.OnPointerOutTrigger,
  122. parameter: ''
  123. },
  124. function() {
  125. // clickbegin = true
  126. // if (true) {
  127. // var mesheses4 = null
  128. // if (transformNodex.getClassName() === 'Mesh') {
  129. // mesheses4 = []
  130. // mesheses4.push(transformNodex)
  131. // }
  132. // for (var i = 0; i < mesheses4.length; i++) {
  133. // try {
  134. // h2.removeMesh(mesheses4[i])
  135. // } catch (error) {
  136. // // alert(error)
  137. // }
  138. // }
  139. // clickbegin = false
  140. if (clickParentRotate) {
  141. isRotating = true
  142. camera.useAutoRotationBehavior = isRotating
  143. }
  144. // }
  145. }
  146. )
  147. )
  148. mesheses[i].actionManager.registerAction(
  149. new BABYLON.ExecuteCodeAction({
  150. trigger: BABYLON.ActionManager.OnPickTrigger,
  151. parameter: ''
  152. },
  153. function() {
  154. clickbegin = true
  155. // if (true) {
  156. try {
  157. cameraClick(transformNodex)
  158. } catch (error) {
  159. // alert(error)
  160. }
  161. // clickbegin = false
  162. // }
  163. })
  164. )
  165. }
  166. }
  167. BABYLON.DefaultLoadingScreen.prototype.hideLoadingUI = function() {
  168. show = 50
  169. document.getElementById('customLoadingScreenDiv').style.display = 'none'
  170. document.getElementById('customLoadingScreenDiv_first').style.display = 'none'
  171. document.title = '全景图'
  172. var prepareGroupButton2ByMesh = function(transformNodex, color, qu) {
  173. var mesheses = null
  174. if (transformNodex.getClassName() === 'Mesh') {
  175. mesheses = []
  176. mesheses.push(transformNodex)
  177. }
  178. for (var i = 0; i < mesheses.length; i++) {
  179. mesheses[i].actionManager = new BABYLON.ActionManager(scene)
  180. // var theScaling = mesheses[i].scaling
  181. /* if (true) {
  182. try {
  183. mesheses[i].actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOutTrigger, mesheses[i], "scaling", new BABYLON.Vector3(theScaling.x, theScaling.y, theScaling.z), 100));
  184. mesheses[i].actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPointerOverTrigger, mesheses[i], "scaling", new BABYLON.Vector3(theScaling.x * 1.01, theScaling.y * 1.01, theScaling.z * 1.01), 100));
  185. } catch (error) {
  186. //alert(error)
  187. }
  188. }*/
  189. // let clickbegin = false
  190. mesheses[i].actionManager.registerAction(
  191. new BABYLON.ExecuteCodeAction({
  192. trigger: BABYLON.ActionManager.OnPointerOverTrigger,
  193. parameter: ''
  194. },
  195. function() {
  196. // clickbegin = true
  197. // if (true) {
  198. if (oldMeshOther != null) {
  199. oldMeshOther.removeBehavior(drag)
  200. var mesheses2 = null
  201. if (oldMeshOther.getClassName() === 'Mesh') {
  202. mesheses2 = []
  203. mesheses2.push(oldMeshOther)
  204. }
  205. for (var i = 0; i < mesheses2.length; i++) {
  206. try {
  207. h2.removeMesh(mesheses2[i])
  208. } catch (error) {
  209. // alert(error)
  210. }
  211. }
  212. }
  213. oldMeshOther = transformNodex
  214. // transformNodex.addBehavior(drag);
  215. var mesheses3 = null
  216. if (transformNodex.getClassName() === 'Mesh') {
  217. mesheses3 = []
  218. mesheses3.push(transformNodex)
  219. }
  220. for (let i = 0; i < mesheses3.length; i++) {
  221. try {
  222. h2.addMesh(mesheses3[i], color)
  223. } catch (error) {
  224. // alert(error)
  225. }
  226. }
  227. // clickbegin = false
  228. isRotating = false
  229. camera.useAutoRotationBehavior = isRotating
  230. // }
  231. }
  232. )
  233. )
  234. // 移出事件
  235. mesheses[i].actionManager.registerAction(
  236. new BABYLON.ExecuteCodeAction({
  237. trigger: BABYLON.ActionManager.OnPointerOutTrigger,
  238. parameter: ''
  239. },
  240. function() {
  241. // clickbegin = true
  242. // if (true) {
  243. var mesheses4 = null
  244. if (transformNodex.getClassName() === 'Mesh') {
  245. mesheses4 = []
  246. mesheses4.push(transformNodex)
  247. }
  248. for (var i = 0; i < mesheses4.length; i++) {
  249. try {
  250. h2.removeMesh(mesheses4[i])
  251. } catch (error) {
  252. // alert(error)
  253. }
  254. }
  255. // clickbegin = false
  256. if (clickParentRotate) {
  257. isRotating = true
  258. camera.useAutoRotationBehavior = isRotating
  259. }
  260. // }
  261. }
  262. )
  263. )
  264. mesheses[i].actionManager.registerAction(
  265. new BABYLON.ExecuteCodeAction({
  266. trigger: BABYLON.ActionManager.OnPickTrigger,
  267. parameter: ''
  268. },
  269. function() {
  270. // clickbegin = true
  271. // if (true) {
  272. try {
  273. // quClick(transformNodex.name)
  274. cameraClick(transformNodex)
  275. } catch (error) {
  276. // alert(error)
  277. }
  278. // clickbegin = false
  279. // }
  280. }
  281. )
  282. )
  283. }
  284. }
  285. // 绑功能点
  286. // var cl = new BABYLON.Color3(0, 0, 1)
  287. // var c2 = new BABYLON.Color3(1, 0, 0)
  288. var smokeAlarms = []
  289. scene.transformNodes.forEach(function(node) {
  290. if (node.name.startsWith('smokealarm')) {
  291. smokeAlarms.push(node)
  292. }
  293. })
  294. var length = smokeAlarms.length
  295. console.log('以 smokealarm 开头的对象数量:', length)
  296. smokeAlarms.forEach(function(jk01, index) {
  297. console.log('smokeAlarms', jk01)
  298. var parts = jk01.name.split('smokealarm')
  299. if (parts.length > 1) {
  300. const paddedIndex = String(index + 1).padStart(3, '0')
  301. jk01.nameID = `S${paddedIndex}`
  302. // jk01.nameID = 'S' + parts[1]
  303. } else {
  304. jk01.nameID = 'S000'
  305. }
  306. jk01.baojing = false
  307. prepareGroupButton2(jk01)
  308. })
  309. // 存储所有 camera 相关的 Mesh
  310. const cameraMeshes = []
  311. scene.meshes.forEach(mesh => {
  312. if (mesh.name.startsWith('camera')) {
  313. cameraMeshes.push(mesh)
  314. }
  315. })
  316. const cameraCount = cameraMeshes.length
  317. console.log('以 camera 开头的 Mesh 数量:', cameraCount)
  318. // 定义颜色
  319. // const colorRed = new BABYLON.Color3(1, 0, 0) // 红
  320. const colorBlue = new BABYLON.Color3(0, 0, 1)
  321. cameraMeshes.forEach((cam, index) => {
  322. const paddedIndex = String(index + 1).padStart(3, '0')
  323. cam.nameID = `C${paddedIndex}`
  324. prepareGroupButton2ByMesh(cam, colorBlue, '摄像头1')
  325. })
  326. // var light = new BABYLON.HemisphericLight('HemiLight', new BABYLON.Vector3(0, 1, 0), scene)
  327. // light.intensity = 2
  328. // light.diffuse = new BABYLON.Color3(0.92, 0.92, 0.92)
  329. // 给vue页面传值,加载完成之后
  330. parent.getIframeLoading('false')
  331. }
  332. BABYLON.DracoCompression.Configuration.decoder.wasmUrl = './js/draco_wasm_wrapper_gltf.js'
  333. BABYLON.DracoCompression.Configuration.decoder.wasmBinaryUrl = './js/draco_decoder_gltf.wasm'
  334. BABYLON.DracoCompression.Configuration.decoder.fallbackUrl = './js/draco_decoder_gltf.js'
  335. // createScene function that creates and return the scene
  336. var createScene = function() {
  337. engine.displayLoadingUI()
  338. // var scene = new BABYLON.Scene(engine)
  339. // camera = new BABYLON.ArcRotateCamera('Camera', 0, 0, 5, new BABYLON.Vector3(0, -1, 0), scene)
  340. // camera.setTarget(new BABYLON.Vector3(0, 0, 0))
  341. // camera.attachControl(canvas, true)
  342. var scene = new BABYLON.Scene(engine)
  343. camera = new BABYLON.ArcRotateCamera(
  344. 'Camera', 6.2782, 0, 500, // alpha=0(水平角度),beta=90°(垂直俯视),radius=200(距离)
  345. new BABYLON.Vector3(0, 0, 0), // 相机位置会根据 alpha/beta/radius 自动计算,无需手动设置
  346. scene
  347. )
  348. camera.setTarget(new BABYLON.Vector3(0, 0, 0)) // 瞄准原点
  349. camera.attachControl(canvas, true)
  350. camera.lowerRadiusLimit = 5.0 // 这里是最大的位置,值越大,物体越小
  351. camera.upperRadiusLimit = 600
  352. camera.inertia = 0.4 // 缩放的快慢
  353. camera.useAutoRotationBehavior = isRotating // 自动旋转
  354. // 改变场景背景颜色 - 背景颜色opacity值设为0,达到透明背景的效果
  355. scene.clearColor = new BABYLON.Color4(0, 0, 0, 0)
  356. scene.activeCamera = camera
  357. scene.activeCamera.useInputToRestoreState = true
  358. // var camera1_status = scene.activeCamera.storeState()
  359. var assetsManager = new BABYLON.AssetsManager(scene)
  360. // var meshTask = assetsManager.addMeshTask('skull task', '', 'asset/', 'F5.glb')
  361. // meshTask.onSuccess = function(task) {
  362. // task.loadedMeshes[0].scaling = new BABYLON.Vector3(0.4, 0.4, 0.4)
  363. // task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0.35, 0)
  364. // }
  365. // meshTask.onError = function(task, message, exception) {
  366. // console.log(message, exception)
  367. // }
  368. // 加载GLB模型并处理材质
  369. BABYLON.SceneLoader.LoadAssetContainerAsync('asset/', 'F5.glb', scene).then((container) => {
  370. // 遍历所有材质
  371. container.materials.forEach(material => {
  372. // 处理标准材质
  373. if (material instanceof BABYLON.StandardMaterial) {
  374. material.backFaceCulling = true // 启用背面剔除
  375. }
  376. // 处理PBR材质
  377. // if (material instanceof BABYLON.PBRMaterial) {
  378. // material.backFaceCulling = true // 启用背面剔除
  379. // }
  380. })
  381. // 将加载的资产添加到场景中
  382. container.addAllToScene()
  383. // setTimeout(() => {
  384. // moveCameraTo('alarm')
  385. // }, 3000)
  386. }).catch((error) => {
  387. console.error('加载模型时出错:', error)
  388. })
  389. var hdrTexture = new BABYLON.CubeTexture.CreateFromPrefilteredData('textures/environmentSpecular.env', scene)
  390. scene.environmentTexture = hdrTexture
  391. var spriteManagerPlayer = new BABYLON.SpriteManager('playerManager', './img/bl9.png', 10, {
  392. width: 100,
  393. height: 100
  394. }, scene)
  395. // spriteManagerPlayer.renderingGroupId = 2;
  396. spriteManagerPlayer.isPickable = true
  397. scene.onPointerDown = function(evt) {
  398. var pickResult = scene.pickSprite(this.pointerX, this.pointerY)
  399. var pick = scene.pick(scene.pointerX, scene.pointerY)
  400. console.log('pick', pick.pickedPoint)
  401. if (pickResult.pickedSprite != null) {
  402. if (pickResult.hit) {
  403. alert(pickResult.pickedSprite.name)
  404. }
  405. }
  406. }
  407. // renderCanvas.style.backgroundImage = 'url("./textures/' + '4' + '.jpg")'
  408. assetsManager.load()
  409. drag = new BABYLON.PointerDragBehavior({
  410. dragPlaneNormal: new BABYLON.Vector3(0, 0, 1)
  411. })
  412. // drag.useObjectOrienationForDragging = false;
  413. drag.validateDrag = (targetPosition) => {
  414. if (targetPosition.x > 10.5 || targetPosition.x < -10.5) {
  415. return false
  416. }
  417. if (targetPosition.z > 10.5 || targetPosition.z < -10.5) {
  418. return false
  419. }
  420. if (oldtransformNodex != null) {
  421. return true
  422. }
  423. }
  424. drag.onDragEndObservable.add((event) => {
  425. // console.log("dragEnd");
  426. // console.log(event);
  427. // console.log(line03_position)
  428. })
  429. // GUI
  430. h1 = new BABYLON.HighlightLayer('hl1', scene)
  431. h2 = new BABYLON.HighlightLayer('hl2', scene)
  432. h3 = new BABYLON.HighlightLayer('hl2', scene)
  433. var step = 0.1
  434. var currentx = 1
  435. // var step2 = 0.1
  436. // var currentx2 = 0.1
  437. h1.blurHorizontalSize = 0.1
  438. // var showx = 0
  439. // var showx2 = 2
  440. // console.log("x4");
  441. scene.registerAfterRender(() => {
  442. h1.blurHorizontalSize = h1.blurVerticalSize + currentx
  443. var nodealert = scene.getTransformNodeByName('yan')
  444. if (nodealert != null) {
  445. var mesheses3 = null
  446. if (nodealert.getClassName() === 'TransformNode') {
  447. mesheses3 = nodealert.getChildMeshes(false)
  448. } else {
  449. mesheses3 = []
  450. mesheses3.push(nodealert)
  451. }
  452. for (var i = 0; i < mesheses3.length; i++) {
  453. try {
  454. if (nodealert.baojing === true) {
  455. h3.addMesh(mesheses3[i], new BABYLON.Color3(1, 0, 0))
  456. } else {
  457. h3.removeMesh(mesheses3[i])
  458. }
  459. } catch (error) {
  460. // alert(error)
  461. }
  462. }
  463. }
  464. })
  465. if (currentx > 0.5) {
  466. step *= -1
  467. }
  468. if (currentx < 0) {
  469. step *= -1
  470. }
  471. currentx += step
  472. return scene
  473. }
  474. var canvas = document.getElementById('renderCanvas')
  475. // load the 3D engine
  476. var engine = new BABYLON.Engine(canvas, true, {
  477. stencil: true
  478. })
  479. // call the createScene function
  480. var scene = createScene()
  481. scene.autoClear = true
  482. scene.imageProcessingConfiguration.exposure = 1
  483. scene.imageProcessingConfiguration.contrast = 1
  484. scene.environmentIntensity = 0.4
  485. engine.runRenderLoop(function() {
  486. scene.render()
  487. })
  488. window.addEventListener('resize', function() {
  489. engine.resize()
  490. })
  491. // 功能转入报警
  492. // function Myalert(MathineID, baojingx) {
  493. // var theName = yangans.get(MathineID)
  494. // if (theName === 'yan') {
  495. // // console.log(scene);
  496. // xx = scene.getTransformNodeByName('yan').baojing = baojingx
  497. // }
  498. // }
  499. // scene.debugLayer.show();
  500. // 报警 true:表示报警, false :表示不报警
  501. function cameraClick(TheCamera) {
  502. window.parent.postMessage(
  503. {
  504. type: 'cameraClick',
  505. data: TheCamera.nameID
  506. },
  507. '*'
  508. )
  509. }
  510. function handleAlarm(deviceId, isAlarm) {
  511. var cl = new BABYLON.Color3(0, 0, 1)
  512. var c2 = new BABYLON.Color3(1, 0, 0)
  513. const targetDevice = scene.transformNodes.find(node => node.nameID === deviceId)
  514. if (targetDevice) {
  515. targetDevice.baojing = isAlarm
  516. var mesheses = null
  517. if (targetDevice.getClassName() === 'TransformNode') {
  518. mesheses = targetDevice.getChildMeshes(false)
  519. } else {
  520. mesheses = []
  521. mesheses.push(targetDevice)
  522. }
  523. if (isAlarm) {
  524. console.log('111')
  525. for (var i = 0; i < mesheses.length; i++) {
  526. h2.addMesh(mesheses[i], c2)
  527. }
  528. } else {
  529. console.log('222')
  530. for (var j = 0; j < mesheses.length; j++) {
  531. h2.removeMesh(mesheses[j])
  532. h2.addMesh(mesheses[j], cl)
  533. }
  534. }
  535. } else {
  536. console.log(`未找到设备 ID 为 ${deviceId} 的设备`)
  537. }
  538. }
  539. window.addEventListener(
  540. 'message',
  541. function(e) {
  542. if (e.data.type === 'deviceState') {
  543. console.log('ddd', e.data.data)
  544. const deviceData = e.data.data
  545. if (Array.isArray(deviceData)) {
  546. deviceData.forEach((device) => {
  547. handleAlarm(device.deviceId, device.isAlarm)
  548. })
  549. } else {
  550. handleAlarm(deviceData.deviceId, deviceData.isAlarm)
  551. }
  552. } else if (e.data.type === 'isGetRotate') {
  553. const isGetRotate = e.data.value
  554. console.log('isGetRotate:', isGetRotate)
  555. // 这里可以添加处理 isGetRotate 的逻辑
  556. toggleAutoRotation(isGetRotate)
  557. }
  558. },
  559. false
  560. )
  561. function toggleAutoRotation(isAutoRotating) {
  562. var camera = scene.activeCamera
  563. clickParentRotate = !isAutoRotating
  564. if (!isAutoRotating) {
  565. // 启用自动旋转
  566. camera.useAutoRotationBehavior = true
  567. } else {
  568. // 禁用自动旋转
  569. camera.useAutoRotationBehavior = false
  570. camera.angularSpeed = 0 // 停止旋转
  571. }
  572. }
  573. // 相机运动到指定视角(带动画)
  574. // function moveCameraTo(targetPreset) {
  575. // // 获取目标参数
  576. // var target = targetAngles[targetPreset]
  577. // if (!target) return console.error('无效的视角预设')
  578. // var camera = scene.activeCamera
  579. // // 禁用用户交互(可选)
  580. // camera.panningInertia = 0 // 禁止平移
  581. // // 创建并设置动画
  582. // var animationAlpha = new BABYLON.Animation(
  583. // 'cameraAlphaAnimation',
  584. // 'alpha',
  585. // 60, // 帧率
  586. // BABYLON.Animation.ANIMATIONTYPE_FLOAT,
  587. // BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT
  588. // )
  589. // var animationBeta = new BABYLON.Animation(
  590. // 'cameraBetaAnimation',
  591. // 'beta',
  592. // 60, // 帧率
  593. // BABYLON.Animation.ANIMATIONTYPE_FLOAT,
  594. // BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT
  595. // )
  596. // var animationRadius = new BABYLON.Animation(
  597. // 'cameraRadiusAnimation',
  598. // 'radius',
  599. // 60, // 帧率
  600. // BABYLON.Animation.ANIMATIONTYPE_FLOAT,
  601. // BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT
  602. // )
  603. // // 定义关键帧
  604. // var keysAlpha = [
  605. // { frame: 0, value: camera.alpha },
  606. // { frame: 120, value: target.alpha }
  607. // ]
  608. // var keysBeta = [
  609. // { frame: 0, value: camera.beta },
  610. // { frame: 120, value: target.beta }
  611. // ]
  612. // var keysRadius = [
  613. // { frame: 0, value: camera.radius },
  614. // { frame: 120, value: target.radius }
  615. // ]
  616. // animationAlpha.setKeys(keysAlpha)
  617. // animationBeta.setKeys(keysBeta)
  618. // animationRadius.setKeys(keysRadius)
  619. // // 设置缓动函数
  620. // var easingFunction = new BABYLON.CubicEase()
  621. // easingFunction.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT)
  622. // animationAlpha.setEasingFunction(easingFunction)
  623. // animationBeta.setEasingFunction(easingFunction)
  624. // animationRadius.setEasingFunction(easingFunction)
  625. // // 开始动画
  626. // scene.beginDirectAnimation(camera, [animationAlpha, animationBeta, animationRadius], 0, 120, false, 1, function() {
  627. // // 动画完成后恢复用户交互
  628. // camera.panningInertia = 0.1
  629. // toggleAutoRotation(true)
  630. // window.parent.postMessage({ type: 'autoRotationStatus', value: true }, '*')
  631. // })
  632. // }