华农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.

684 lines
21 KiB

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