1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=e(require("react")),n=e(require("../controllers/animation-controller")),o=e(require("lodash")),i=e(require("path")),r=e(require("../../atom-react/components/jibo-combo-box")),a=[{label:"Front",display:"front",value:"front"},{label:"Back",display:"back",value:"back"},{label:"Left",display:"left",value:"left"},{label:"Right",display:"right",value:"right"}],s=t.createClass({displayName:"layout-child",componentWillMount:function(){this.controller=new n(this.props.animationModel),this.lastWidth=this.props.width,this.lastHeight=this.props.height,this.requestAnimationID=window.requestAnimationFrame(this.updateLoop.bind(this))},updateLoop:function(){if(this.controller.renderer){var e=this.props.animationModel.evaluateAllDOFLayers();e=o.extend({},o.cloneDeep(this.controller.robotInfo.getDefaultDOFValues()),o.cloneDeep(e));for(var t in e){var n=e[t];("eyeTextureInfixBn_r"===t||"overlayTextureInfixBn_r"===t||"screenBGTextureInfixBn_r"===t)&&(n="file://"+i.resolve(this.props.animationModel.projectRoot,n)),e[t]=n}this.controller.updateDofValues(e),this.controller.update()}this.requestAnimationID=window.requestAnimationFrame(this.updateLoop.bind(this))},componentDidMount:function(){var e=t.findDOMNode(this.refs.preview);this.controller.initialize(e,function(){}),e.addEventListener("contextmenu",function(e){return"CANVAS"===e.target.tagName?(e.preventDefault(),e.stopPropagation(),!1):!0},!1)},componentWillUnmount:function(){this.requestAnimationID&&window.cancelAnimationFrame(this.requestAnimationID),this.controller.dispose()},onMouseDown:function(){return!1},onMouseDownCapture:function(){return!1},onChangeCamera:function(e){this.controller.setCamera(e.value)},onBackgroundColor:function(){},onReset:function(){this.controller.setCamera(a[0].value)},render:function(){this.controller&&this.controller.renderer&&(this.lastWidth!==this.props.width||this.lastHeight!==this.props.height)&&(this.controller.renderer.scene.handleResize(),this.lastWidth=this.props.width,this.lastHeight=this.props.height);var e={reset:{position:"absolute",marginLeft:90,marginTop:10},comboBox:{position:"absolute",margin:10}};return t.createElement("div",{tabIndex:1,ref:"preview",className:"animation-preview"},t.createElement("div",{className:"block",style:e.reset},t.createElement("button",{className:"btn icon icon-sync inline-block-tight",onClick:this.onReset},"Reset")),t.createElement("div",{style:e.comboBox},t.createElement(r,{data:a,init:a[0],onSelected:this.onChangeCamera})))}});module.exports=s; |